Skip to content

Unhelpful/misleading Parse error Unexpected '{' when source has bad indents #2144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dkamins opened this issue Feb 26, 2012 · 1 comment
Closed
Labels

Comments

@dkamins
Copy link

dkamins commented Feb 26, 2012

This was originally filed as Issue #2141, but it actually has nothing to do with tabs, and that issue was closed amid argument about tabs vs. spaces. Moving on...

The actual issue is that in the presence of invalid indents (e.g. see example below), the parser error Unexpected '{' is confusing, misleading, and incorrect. In this trivial example, it's easy to see what's wrong, but in a larger file with actual "{" chars, and especially for users new to CoffeeScript syntax, the error is very misleading.

Surely there is a more friendly error message such as "Unexpected Indent" or something similar that would be more appropriate than blaming the user for typing a character that doesn't even exist.

foo:
  spaces: 2
    spaces: 4
Error: In test.coffee, Parse error on line 3: Unexpected '{'
    at Object.parseError (/opt/local/lib/node_modules/coffee-script/lib/coffee-script/parser.js:470:11)
    at Object.parse (/opt/local/lib/node_modules/coffee-script/lib/coffee-script/parser.js:546:22)
    at Object.compile (/opt/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:40:22)
    at /opt/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:140:33
    at /opt/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:110:18
    at [object Object].<anonymous> (fs.js:115:5)
    at [object Object].emit (events.js:64:17)
    at afterRead (fs.js:1112:12)
    at Object.wrapper [as oncomplete] (fs.js:254:17)
@michaelficarra
Copy link
Collaborator

Duplicate #1096, #1486. See #2160.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants