Parse let declarations whose id starts with \ (#13325)

This commit is contained in:
Nicolò Ribaudo 2021-05-17 15:46:59 +02:00 committed by GitHub
parent 229a5481f4
commit c2181343f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 1 deletions

View File

@ -188,7 +188,13 @@ export default class StatementParser extends ExpressionParser {
// Statement) is allowed here. If context is not empty then only a Statement // Statement) is allowed here. If context is not empty then only a Statement
// is allowed. However, `let [` is an explicit negative lookahead for // is allowed. However, `let [` is an explicit negative lookahead for
// ExpressionStatement, so special-case it first. // 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 (context) return false;
if (nextCh === charCodes.leftCurlyBrace) return true; if (nextCh === charCodes.leftCurlyBrace) return true;

View File

@ -0,0 +1 @@
let \u0275ResourceLoaderImpl_BaseFactory

View 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": []
}
}

View File

@ -0,0 +1,2 @@
1 + let
\u0275ResourceLoaderImpl_BaseFactory

View 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": []
}
}