Parse let declarations whose id starts with \ (#13325)
This commit is contained in:
parent
229a5481f4
commit
c2181343f1
@ -188,7 +188,13 @@ export default class StatementParser extends ExpressionParser {
|
||||
// Statement) is allowed here. If context is not empty then only a Statement
|
||||
// is allowed. However, `let [` is an explicit negative lookahead for
|
||||
// ExpressionStatement, so special-case it first.
|
||||
if (nextCh === charCodes.leftSquareBracket) return true;
|
||||
// Also, `let \` is never valid as an expression so this must be a keyword.
|
||||
if (
|
||||
nextCh === charCodes.backslash ||
|
||||
nextCh === charCodes.leftSquareBracket
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (context) return false;
|
||||
|
||||
if (nextCh === charCodes.leftCurlyBrace) return true;
|
||||
|
||||
1
packages/babel-parser/test/fixtures/es2015/let/let-declaration-escape-id/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2015/let/let-declaration-escape-id/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
let \u0275ResourceLoaderImpl_BaseFactory
|
||||
30
packages/babel-parser/test/fixtures/es2015/let/let-declaration-escape-id/output.json
vendored
Normal file
30
packages/babel-parser/test/fixtures/es2015/let/let-declaration-escape-id/output.json
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start":4,"end":40,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":40}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":40,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":40},"identifierName":"ɵResourceLoaderImpl_BaseFactory"},
|
||||
"name": "ɵResourceLoaderImpl_BaseFactory"
|
||||
},
|
||||
"init": null
|
||||
}
|
||||
],
|
||||
"kind": "let"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/es2015/let/let-expression-followed-by-escape/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/es2015/let/let-expression-followed-by-escape/input.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
1 + let
|
||||
\u0275ResourceLoaderImpl_BaseFactory
|
||||
45
packages/babel-parser/test/fixtures/es2015/let/let-expression-followed-by-escape/output.json
vendored
Normal file
45
packages/babel-parser/test/fixtures/es2015/let/let-expression-followed-by-escape/output.json
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":36}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":36}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":7,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":7}},
|
||||
"expression": {
|
||||
"type": "BinaryExpression",
|
||||
"start":0,"end":7,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":7}},
|
||||
"left": {
|
||||
"type": "NumericLiteral",
|
||||
"start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1}},
|
||||
"extra": {
|
||||
"rawValue": 1,
|
||||
"raw": "1"
|
||||
},
|
||||
"value": 1
|
||||
},
|
||||
"operator": "+",
|
||||
"right": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":7,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":7},"identifierName":"let"},
|
||||
"name": "let"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":8,"end":44,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":36}},
|
||||
"expression": {
|
||||
"type": "Identifier",
|
||||
"start":8,"end":44,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":36},"identifierName":"ɵResourceLoaderImpl_BaseFactory"},
|
||||
"name": "ɵResourceLoaderImpl_BaseFactory"
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user