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

POST-for-in expression with implicit function call crashes #333

Closed
eventualbuddha opened this issue Jul 20, 2016 · 3 comments · Fixed by decaffeinate/decaffeinate-parser#74
Assignees
Labels

Comments

@eventualbuddha
Copy link
Collaborator

decaffeinate is crashing on my CoffeeScript input:

(a for a in b c)

(repl)

I get this error:

unexpected ')' at 22

The fix for this is probably similar to #330.

@niieani
Copy link

niieani commented Jul 20, 2016

I'm actually getting:

unexpected then

With this code:

(b for b in (c))

http://decaffeinate-project.org/repl/#?evaluate=false&code=(b%20for%20b%20in%20(c))

@madskonradsen
Copy link
Contributor

Looks like the initial issue have been fixed, but @niieani 's issue does still exist

@alangpierce
Copy link
Member

Great, thanks for calling that out. I guess we should keep this open track the other issue. I haven't looked at it too deeply, but I suspect that the original issue was fixed with Rich-Harris/magic-string#89 .

@alangpierce alangpierce self-assigned this Nov 13, 2016
alangpierce added a commit to alangpierce/decaffeinate-parser that referenced this issue Nov 13, 2016
Fixes decaffeinate/decaffeinate#333
Fixes decaffeinate/decaffeinate#502

The code to fix CoffeeScript location data was incorrectly assuming that the
last node of a loop is the loop body, but that isn't true in postfix loops, so
it was causing the end location to be artificially early. Probably, the ideal
behavior (assuming location data actually needs to be fixed here) is to take the
max of all nodes, but that didn't seem trivial. Instead, an easy fix is to just
do the same thing we do for the `if` case: just use the body to extend the
bounds if necessary, but never shrink it. This also seems more robust in
general, probably. At the very least, it's really simple and doesn't break any
decaffeinate tests.
alangpierce added a commit to decaffeinate/decaffeinate-parser that referenced this issue Nov 13, 2016
Fixes decaffeinate/decaffeinate#333
Fixes decaffeinate/decaffeinate#502

The code to fix CoffeeScript location data was incorrectly assuming that the
last node of a loop is the loop body, but that isn't true in postfix loops, so
it was causing the end location to be artificially early. Probably, the ideal
behavior (assuming location data actually needs to be fixed here) is to take the
max of all nodes, but that didn't seem trivial. Instead, an easy fix is to just
do the same thing we do for the `if` case: just use the body to extend the
bounds if necessary, but never shrink it. This also seems more robust in
general, probably. At the very least, it's really simple and doesn't break any
decaffeinate tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants