Skip to content

Commit 8e73ff5

Browse files
Parse let declarations whose id starts with \
1 parent 229a548 commit 8e73ff5

5 files changed

Lines changed: 85 additions & 1 deletion

File tree

packages/babel-parser/src/parser/statement.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,13 @@ export default class StatementParser extends ExpressionParser {
188188
// Statement) is allowed here. If context is not empty then only a Statement
189189
// is allowed. However, `let [` is an explicit negative lookahead for
190190
// ExpressionStatement, so special-case it first.
191-
if (nextCh === charCodes.leftSquareBracket) return true;
191+
// Also, `let \` is never valid as an expression so this must be a keyword.
192+
if (
193+
nextCh === charCodes.backslash ||
194+
nextCh === charCodes.leftSquareBracket
195+
) {
196+
return true;
197+
}
192198
if (context) return false;
193199

194200
if (nextCh === charCodes.leftCurlyBrace) return true;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let \u0275ResourceLoaderImpl_BaseFactory
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"type": "File",
3+
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}},
4+
"program": {
5+
"type": "Program",
6+
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}},
7+
"sourceType": "script",
8+
"interpreter": null,
9+
"body": [
10+
{
11+
"type": "VariableDeclaration",
12+
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}},
13+
"declarations": [
14+
{
15+
"type": "VariableDeclarator",
16+
"start":4,"end":40,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":40}},
17+
"id": {
18+
"type": "Identifier",
19+
"start":4,"end":40,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":40},"identifierName":"ɵResourceLoaderImpl_BaseFactory"},
20+
"name": "ɵResourceLoaderImpl_BaseFactory"
21+
},
22+
"init": null
23+
}
24+
],
25+
"kind": "let"
26+
}
27+
],
28+
"directives": []
29+
}
30+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1 + let
2+
\u0275ResourceLoaderImpl_BaseFactory
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"type": "File",
3+
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":36}},
4+
"program": {
5+
"type": "Program",
6+
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":36}},
7+
"sourceType": "script",
8+
"interpreter": null,
9+
"body": [
10+
{
11+
"type": "ExpressionStatement",
12+
"start":0,"end":7,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":7}},
13+
"expression": {
14+
"type": "BinaryExpression",
15+
"start":0,"end":7,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":7}},
16+
"left": {
17+
"type": "NumericLiteral",
18+
"start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1}},
19+
"extra": {
20+
"rawValue": 1,
21+
"raw": "1"
22+
},
23+
"value": 1
24+
},
25+
"operator": "+",
26+
"right": {
27+
"type": "Identifier",
28+
"start":4,"end":7,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":7},"identifierName":"let"},
29+
"name": "let"
30+
}
31+
}
32+
},
33+
{
34+
"type": "ExpressionStatement",
35+
"start":8,"end":44,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":36}},
36+
"expression": {
37+
"type": "Identifier",
38+
"start":8,"end":44,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":36},"identifierName":"ɵResourceLoaderImpl_BaseFactory"},
39+
"name": "ɵResourceLoaderImpl_BaseFactory"
40+
}
41+
}
42+
],
43+
"directives": []
44+
}
45+
}

0 commit comments

Comments
 (0)