Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle exprAllowed before ObjectLike is parsed (#12267)
* fix: disallow expression after `}` is consumed in parseObjectLike * refactor: avoid accessing this.prodParam in context update
- Loading branch information
Showing
6 changed files
with
166 additions
and
11 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
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
packages/babel-parser/test/fixtures/core/categorized/labeled-block-statement-regex/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 : { b : 1 }/2/; |
64 changes: 64 additions & 0 deletions
64
...ges/babel-parser/test/fixtures/core/categorized/labeled-block-statement-regex/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,64 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "LabeledStatement", | ||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":4,"end":13,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":13}}, | ||
"body": [ | ||
{ | ||
"type": "LabeledStatement", | ||
"start":6,"end":11,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":11}}, | ||
"body": { | ||
"type": "ExpressionStatement", | ||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11}}, | ||
"expression": { | ||
"type": "NumericLiteral", | ||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11}}, | ||
"extra": { | ||
"rawValue": 1, | ||
"raw": "1" | ||
}, | ||
"value": 1 | ||
} | ||
}, | ||
"label": { | ||
"type": "Identifier", | ||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"b"}, | ||
"name": "b" | ||
} | ||
} | ||
], | ||
"directives": [] | ||
}, | ||
"label": { | ||
"type": "Identifier", | ||
"start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"a"}, | ||
"name": "a" | ||
} | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":13,"end":17,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":17}}, | ||
"expression": { | ||
"type": "RegExpLiteral", | ||
"start":13,"end":16,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":16}}, | ||
"extra": { | ||
"raw": "/2/" | ||
}, | ||
"pattern": "2", | ||
"flags": "" | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/core/categorized/ternary-object-literal-divide/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 @@ | ||
0 ? a : { b : 1 }/2; |
76 changes: 76 additions & 0 deletions
76
...ges/babel-parser/test/fixtures/core/categorized/ternary-object-literal-divide/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,76 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, | ||
"expression": { | ||
"type": "ConditionalExpression", | ||
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, | ||
"test": { | ||
"type": "NumericLiteral", | ||
"start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1}}, | ||
"extra": { | ||
"rawValue": 0, | ||
"raw": "0" | ||
}, | ||
"value": 0 | ||
}, | ||
"consequent": { | ||
"type": "Identifier", | ||
"start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5},"identifierName":"a"}, | ||
"name": "a" | ||
}, | ||
"alternate": { | ||
"type": "BinaryExpression", | ||
"start":8,"end":19,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":19}}, | ||
"left": { | ||
"type": "ObjectExpression", | ||
"start":8,"end":17,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":17}}, | ||
"properties": [ | ||
{ | ||
"type": "ObjectProperty", | ||
"start":10,"end":15,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":15}}, | ||
"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": "NumericLiteral", | ||
"start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15}}, | ||
"extra": { | ||
"rawValue": 1, | ||
"raw": "1" | ||
}, | ||
"value": 1 | ||
} | ||
} | ||
] | ||
}, | ||
"operator": "/", | ||
"right": { | ||
"type": "NumericLiteral", | ||
"start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}}, | ||
"extra": { | ||
"rawValue": 2, | ||
"raw": "2" | ||
}, | ||
"value": 2 | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |