fix: properly parse member expression after property initializer#11031
Merged
nicolo-ribaudo merged 1 commit intobabel:masterfrom Jan 19, 2020
vedantroy:fix-10989
Merged
fix: properly parse member expression after property initializer#11031nicolo-ribaudo merged 1 commit intobabel:masterfrom vedantroy:fix-10989
nicolo-ribaudo merged 1 commit intobabel:masterfrom
vedantroy:fix-10989
Conversation
Fixes issue 10989 where the only the identifier in a member expression that is the value of an object property would be parsed. Removing checkExpressionErrors in parseExprSubscripts results in the subscript also being parsed.
JLHwung
reviewed
Jan 19, 2020
| return expr; | ||
| } | ||
|
|
||
| if (this.checkExpressionErrors(refExpressionErrors, false)) { |
Contributor
There was a problem hiding this comment.
We should investigate if the other this.checkExpressionErrors(refExpressionErrors, false) checks are necessary. They are not caught by any test cases in babel-parser now.
(They are not even caught by acorn testcases)
Contributor
Author
There was a problem hiding this comment.
I will look into removing the other instances of this.checkExpressionErrors(refExpressionErrors, false). I didn't remove them in this PR because it wasn't necessary to fix the bug, but I can always add some more changes to this PR/open a new one.
JLHwung
approved these changes
Jan 19, 2020
nicolo-ribaudo
approved these changes
Jan 19, 2020
Member
|
Thanks! |
This was referenced Feb 24, 2020
This was referenced Mar 7, 2020
This was referenced Mar 14, 2020
This was referenced Mar 25, 2020
This was referenced Apr 2, 2020
This was referenced Apr 9, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes issue 10989 where only the identifier in a member expression that is the value of an object property would be parsed. Removing
checkExpressionErrorsinparseExprSubscriptsresults in the subscript also being parsed.When parsing
({a = 42, b: test.d} = {}), Babel expects a "," aftertest. This is because Babel only parsestestinstead oftest.d. So it expects a comma afterb: test, since it believes a new object property is starting. This happens because insideparseExprSubscripts,this.checkExpressionErrors(refExpressionErrors, false)returnstrue, which causes the method to return early and not callthis.parseSubscripts(expr, startPos, startLoc). Removing that check allowsparseSubscriptsto be called, resulting intest.dto be parsed as the object property value.