Fix param parser constructor
scanning
#391
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.
When parsing an identifier, the parser will treat
this.constructor
as a single identifier, which means it won't match theconstructor
token we are looking for when scanning for a constructor. However, when usingthis?.constructor
, 2 identifier tokens would be yielded:this
andconstructor
, which made the parser wrongfully assume it found the constructor. To fix this, theIDENT_PART_EXPR
now includes?
as a valid identifier part in order to reduce the amount of false-positiveconstructor
tokens.However, as I was looking into this, I realized that if you do
Since
constructor
is still a valid identifier despite being a reserved keyword, JS allows this, which would similarly make the parser think it found the constructor.To fix this, the parser will now check if the
constructor
token is followed by a(
token to consider it a valid constructor. The only false-positive that will get past these checks isBut I don't think that's a case that's common enough to worry about. Fixing that would require a more complex parser, which will affect performance.
Closes #390