Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: properly parse member expression after property initializ… (#11031)
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.
- Loading branch information
1 parent
85ddc29
commit 341964b
Showing
5 changed files
with
557 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
1 change: 1 addition & 0 deletions
1
...-parser/test/fixtures/core/object/member-expression-after-property-initializer-1/input.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
({a = 42, b: test.d} = {}) |
278 changes: 278 additions & 0 deletions
278
...rser/test/fixtures/core/object/member-expression-after-property-initializer-1/output.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,278 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 26, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 26 | ||
} | ||
}, | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 26, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 26 | ||
} | ||
}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start": 0, | ||
"end": 26, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 26 | ||
} | ||
}, | ||
"expression": { | ||
"type": "AssignmentExpression", | ||
"start": 1, | ||
"end": 25, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 1 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 25 | ||
} | ||
}, | ||
"operator": "=", | ||
"left": { | ||
"type": "ObjectPattern", | ||
"start": 1, | ||
"end": 20, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 1 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 20 | ||
} | ||
}, | ||
"properties": [ | ||
{ | ||
"type": "ObjectProperty", | ||
"start": 2, | ||
"end": 8, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 2 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 8 | ||
} | ||
}, | ||
"method": false, | ||
"key": { | ||
"type": "Identifier", | ||
"start": 2, | ||
"end": 3, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 2 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 3 | ||
}, | ||
"identifierName": "a" | ||
}, | ||
"name": "a" | ||
}, | ||
"computed": false, | ||
"shorthand": true, | ||
"value": { | ||
"type": "AssignmentPattern", | ||
"start": 2, | ||
"end": 8, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 2 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 8 | ||
} | ||
}, | ||
"left": { | ||
"type": "Identifier", | ||
"start": 2, | ||
"end": 3, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 2 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 3 | ||
}, | ||
"identifierName": "a" | ||
}, | ||
"name": "a" | ||
}, | ||
"right": { | ||
"type": "NumericLiteral", | ||
"start": 6, | ||
"end": 8, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 6 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 8 | ||
} | ||
}, | ||
"extra": { | ||
"rawValue": 42, | ||
"raw": "42" | ||
}, | ||
"value": 42 | ||
} | ||
}, | ||
"extra": { | ||
"shorthand": true | ||
} | ||
}, | ||
{ | ||
"type": "ObjectProperty", | ||
"start": 10, | ||
"end": 19, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 10 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 19 | ||
} | ||
}, | ||
"method": false, | ||
"key": { | ||
"type": "Identifier", | ||
"start": 10, | ||
"end": 11, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 10 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 11 | ||
}, | ||
"identifierName": "b" | ||
}, | ||
"name": "b" | ||
}, | ||
"computed": false, | ||
"shorthand": false, | ||
"value": { | ||
"type": "MemberExpression", | ||
"start": 13, | ||
"end": 19, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 13 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 19 | ||
} | ||
}, | ||
"object": { | ||
"type": "Identifier", | ||
"start": 13, | ||
"end": 17, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 13 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 17 | ||
}, | ||
"identifierName": "test" | ||
}, | ||
"name": "test" | ||
}, | ||
"property": { | ||
"type": "Identifier", | ||
"start": 18, | ||
"end": 19, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 18 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 19 | ||
}, | ||
"identifierName": "d" | ||
}, | ||
"name": "d" | ||
}, | ||
"computed": false | ||
} | ||
} | ||
] | ||
}, | ||
"right": { | ||
"type": "ObjectExpression", | ||
"start": 23, | ||
"end": 25, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 23 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 25 | ||
} | ||
}, | ||
"properties": [] | ||
}, | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 0 | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...-parser/test/fixtures/core/object/member-expression-after-property-initializer-2/input.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
({a = 42, b: {}.d} = {}) |
Oops, something went wrong.