Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
Fix incorrect parse async with proto-identifier-shorthand
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingwl authored and ariya committed Sep 9, 2017
1 parent 08a31db commit 1e6ca4b
Show file tree
Hide file tree
Showing 3 changed files with 300 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ export class Parser {
this.nextToken();
computed = this.match('[');
isAsync = !this.hasLineTerminator && (id === 'async') &&
!this.match(':') && !this.match('(') && !this.match('*');
!this.match(':') && !this.match('(') && !this.match('*') && !this.match(',');
key = isAsync ? this.parseObjectPropertyKey() : this.finalize(node, new Node.Identifier(id));
} else if (this.match('*')) {
this.nextToken();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
({ async, __proto__ })
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
{
"type": "Program",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "ObjectExpression",
"properties": [
{
"type": "Property",
"key": {
"type": "Identifier",
"name": "async",
"range": [
3,
8
],
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 8
}
}
},
"computed": false,
"value": {
"type": "Identifier",
"name": "async",
"range": [
3,
8
],
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 8
}
}
},
"kind": "init",
"method": false,
"shorthand": true,
"range": [
3,
8
],
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 8
}
}
},
{
"type": "Property",
"key": {
"type": "Identifier",
"name": "__proto__",
"range": [
10,
19
],
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 19
}
}
},
"computed": false,
"value": {
"type": "Identifier",
"name": "__proto__",
"range": [
10,
19
],
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 19
}
}
},
"kind": "init",
"method": false,
"shorthand": true,
"range": [
10,
19
],
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 19
}
}
}
],
"range": [
1,
21
],
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 21
}
}
},
"range": [
0,
22
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 22
}
}
}
],
"sourceType": "script",
"tokens": [
{
"type": "Punctuator",
"value": "(",
"range": [
0,
1
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
}
},
{
"type": "Punctuator",
"value": "{",
"range": [
1,
2
],
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 2
}
}
},
{
"type": "Identifier",
"value": "async",
"range": [
3,
8
],
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 8
}
}
},
{
"type": "Punctuator",
"value": ",",
"range": [
8,
9
],
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 9
}
}
},
{
"type": "Identifier",
"value": "__proto__",
"range": [
10,
19
],
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 19
}
}
},
{
"type": "Punctuator",
"value": "}",
"range": [
20,
21
],
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 21
}
}
},
{
"type": "Punctuator",
"value": ")",
"range": [
21,
22
],
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 22
}
}
}
],
"range": [
0,
22
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 22
}
}
}

0 comments on commit 1e6ca4b

Please sign in to comment.