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.
Hi! Currently, there is a subtle difference in the way
language-javascript
deals with auto semicolons when comments are present.Let's have a look at this code sample:
And how esprima parses it:
As you can see, the parser is introducing an automatic semicolon in all the four scenarios. This behavior is consistent with modern V8 and SpiderMonkey engines.
However, let's have a look at how
language-javascript
handles these scenarios. If you add the following tests toProgramParser.hs
......only the fourth and last test will actually produce the expected results. The other three will fail with the same error:
In other words, this parser is only inserting an automatic semicolon after a newline, but not after comments. This PR fixes this issue.
I have also refactored the
Lexer
tests, so that they don't just inspect the tokens produced byalex
, but also those sent tohappy
.