Skip to content

Fix inadvertent automatic semicolon insertion#36

Open
scottrobertwhittaker wants to merge 2 commits into
tenderlove:masterfrom
scottrobertwhittaker:fix-inadvertent-ASI
Open

Fix inadvertent automatic semicolon insertion#36
scottrobertwhittaker wants to merge 2 commits into
tenderlove:masterfrom
scottrobertwhittaker:fix-inadvertent-ASI

Conversation

@scottrobertwhittaker
Copy link
Copy Markdown

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