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

fix: don't shrink loop bounds by assuming the body is at the end #74

Merged
merged 1 commit into from
Nov 13, 2016

Conversation

alangpierce
Copy link
Member

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.

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 alangpierce merged commit 16b0596 into decaffeinate:master Nov 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wrapping when clause in paren causes error POST-for-in expression with implicit function call crashes
1 participant