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 inadvertent automatic semicolon insertion #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

scottrobertwhittaker
Copy link

This patch fixes a bug in RKelly's automatic semicolon insertion logic: though the ECMAScript standard specifies that automatic semicolon insertion never takes place within the header of a for loop, this valid code would fail to parse:

    for(a;
        b;
        ++c) { /* ... */ }

...because RKelly erroneously attempts to insert a semicolon after b, which would be a valid insertion anywhere outside the header of a for loop.

To fix this, this modifies RKelly::Parser to explicitly track when we're inside the loop header, including any nested parenthetical sub-expressions, so it won't attempt to insert a semicolon.

(CCing @nene for rkelly-remix, too.)

This patch fixes a bug in RKelly's automatic semicolon insertion logic: though
the ECMAScript standard specifies that automatic semicolon insertion never
takes place within the header of a `for` loop, this valid code would fail to
parse:

        for(a;
            b;
            ++c) { /* ... */ }

...because RKelly erroneously attempts to insert a semicolon after `b`, which
would be a valid insertion anywhere outside the header of a `for` loop.

To fix this, this modifies `RKelly::Parser` to explicitly track when we're
inside the loop header, including any nested parenthetical sub-expressions, so
it won't attempt to insert a semicolon.
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.

1 participant