Skip to content
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

else binds to wrong if #131

Closed
goto-bus-stop opened this issue May 6, 2012 · 2 comments
Closed

else binds to wrong if #131

goto-bus-stop opened this issue May 6, 2012 · 2 comments
Labels

Comments

@goto-bus-stop
Copy link

if b then if c then d else e

compiles to

if (b) {
  if (c) {
    d;
  }
} else {
  e;
}

and

switch a
case b then if c then d else e

fails.

In the first case, I'd expect the else to bind to the innermost if,

if (b) {
  if (c) {
    d;
  } else {
    e;
  }
}

And it's quite the same with the switch case, except of course that a case doesn't take an else and therefore fails to compile.
It kind of dedents implicit blocks (too?) enthusiastically:
if a then if c then b else e
=>
IF ID:a INDENT:0 IF ID:c INDENT:0 ID:b DEDENT:0 DEDENT:0 ELSE INDENT:0 ID:e DEDENT:0 NEWLINE:\n

@satyr
Copy link
Owner

satyr commented May 6, 2012

See #127. This is an inherent defect of CoffeeScript's then.

@goto-bus-stop
Copy link
Author

Woops, I actually read through that issue before but, apparently, forgot...

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