Skip to content

Commit

Permalink
fix: allow escaped sequence in private in
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung authored and jridgewell committed May 9, 2020
1 parent dc90c7e commit a19930f
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/babel-parser/src/parser/expression.js
Expand Up @@ -1140,7 +1140,8 @@ export default class ExpressionParser extends LValParser {
return this.finishNode(node, "PipelinePrimaryTopicReference");
}

if (isIdentifierStart(this.input.codePointAt(this.state.end))) {
const nextCh = this.input.codePointAt(this.state.end);
if (isIdentifierStart(nextCh) || nextCh === charCodes.backslash) {
const start = this.state.start;
node = (this.parseMaybePrivateName(true): N.PrivateName);
if (this.match(tt._in)) {
Expand Down
@@ -0,0 +1,6 @@
class Foo {
#\u{61} = 1;
test() {
#\u{61} in {};
}
}
@@ -0,0 +1,3 @@
{
"plugins": ["classPrivateProperties", "privateIn"]
}
@@ -0,0 +1,98 @@
{
"type": "File",
"start":0,"end":62,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}},
"program": {
"type": "Program",
"start":0,"end":62,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start":0,"end":62,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}},
"id": {
"type": "Identifier",
"start":6,"end":9,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":9},"identifierName":"Foo"},
"name": "Foo"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start":10,"end":62,"loc":{"start":{"line":1,"column":10},"end":{"line":6,"column":1}},
"body": [
{
"type": "ClassPrivateProperty",
"start":14,"end":26,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":14}},
"static": false,
"key": {
"type": "PrivateName",
"start":14,"end":21,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":9}},
"id": {
"type": "Identifier",
"start":15,"end":21,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":9},"identifierName":"a"},
"name": "a"
}
},
"value": {
"type": "NumericLiteral",
"start":24,"end":25,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":13}},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
},
{
"type": "ClassMethod",
"start":29,"end":60,"loc":{"start":{"line":3,"column":2},"end":{"line":5,"column":3}},
"static": false,
"key": {
"type": "Identifier",
"start":29,"end":33,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":6},"identifierName":"test"},
"name": "test"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start":36,"end":60,"loc":{"start":{"line":3,"column":9},"end":{"line":5,"column":3}},
"body": [
{
"type": "ExpressionStatement",
"start":42,"end":56,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":18}},
"expression": {
"type": "BinaryExpression",
"start":42,"end":55,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":17}},
"left": {
"type": "PrivateName",
"start":42,"end":49,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":11}},
"id": {
"type": "Identifier",
"start":43,"end":49,"loc":{"start":{"line":4,"column":5},"end":{"line":4,"column":11},"identifierName":"a"},
"name": "a"
}
},
"operator": "in",
"right": {
"type": "ObjectExpression",
"start":53,"end":55,"loc":{"start":{"line":4,"column":15},"end":{"line":4,"column":17}},
"properties": []
}
}
}
],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

0 comments on commit a19930f

Please sign in to comment.