Skip to content

Commit

Permalink
Parse let declarations whose id starts with \ (#13325)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed May 17, 2021
1 parent 229a548 commit c218134
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/babel-parser/src/parser/statement.js
Expand Up @@ -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;
Expand Down
@@ -0,0 +1 @@
let \u0275ResourceLoaderImpl_BaseFactory
@@ -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": []
}
}
@@ -0,0 +1,2 @@
1 + let
\u0275ResourceLoaderImpl_BaseFactory
@@ -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": []
}
}

0 comments on commit c218134

Please sign in to comment.