Fix: for in / of statements containing new lines #332
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The impact of this diff is that inputs like the following will parse correctly
Previously, this would result in this AST because automatic semicolons would be inserted
Now this parses as
Note that before this patch this behavior could result in more severe parse failures as
becoming
This diff addresses an issue with the way the
for_statement
handles semicolonsPreviously the
for_statement
did not require semicolons. Note that requiring the semicolon literal is not overly restrictive because automatic semicolons are disallowed by the spec within for statements:The for statement also previously considered itself composed of
expression_statement
s but this is problematic for having real semicolons that arent consumed by$._semicolon
sThe spec's discussion of the for statement also considers the
for_statement
to be composed of expressions, not expression statements. So this PR alters that as well.With this setup, I can add an an optional automatic semicolon to the
_for_header
used by thefor_in_statement
so that GLR can kick in and disambiguate rather than consideringfor(let x <newline>
to be concretely afor_statement