Skip to content

Commit

Permalink
Fix: parsing error on async as property name. (#295)
Browse files Browse the repository at this point in the history
* Fix: parsing error on `async` as property name.

* add a test for `async` as variable name.
  • Loading branch information
mysticatea authored and nzakas committed Sep 26, 2016
1 parent 6606f63 commit 9810bab
Show file tree
Hide file tree
Showing 5 changed files with 449 additions and 0 deletions.
1 change: 1 addition & 0 deletions espree.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ acorn.plugins.espree = function(instance) {
prop.key.type === "Identifier" &&
prop.key.name === "async" &&
this.type !== tt.parenL &&
this.type !== tt.colon &&
!this.canInsertSemicolon()
) {
this.parsePropertyName(prop/* , refDestructuringErrors */);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
module.exports = {
"type": "Program",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"range": [
0,
13
],
"body": [
{
"type": "ExpressionStatement",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"range": [
0,
13
],
"expression": {
"type": "ObjectExpression",
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 11
}
},
"range": [
1,
11
],
"properties": [
{
"type": "Property",
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 10
}
},
"range": [
2,
10
],
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 7
}
},
"range": [
2,
7
],
"name": "async"
},
"value": {
"type": "Literal",
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
},
"range": [
9,
10
],
"value": 1,
"raw": "1"
},
"kind": "init"
}
]
}
}
],
"sourceType": "script",
"tokens": [
{
"type": "Punctuator",
"value": "(",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
},
"range": [
0,
1
]
},
{
"type": "Punctuator",
"value": "{",
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 2
}
},
"range": [
1,
2
]
},
{
"type": "Identifier",
"value": "async",
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 7
}
},
"range": [
2,
7
]
},
{
"type": "Punctuator",
"value": ":",
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 8
}
},
"range": [
7,
8
]
},
{
"type": "Numeric",
"value": "1",
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
},
"range": [
9,
10
]
},
{
"type": "Punctuator",
"value": "}",
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
}
},
"range": [
10,
11
]
},
{
"type": "Punctuator",
"value": ")",
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
}
},
"range": [
11,
12
]
},
{
"type": "Punctuator",
"value": ";",
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 13
}
},
"range": [
12,
13
]
}
]
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
({async: 1});

0 comments on commit 9810bab

Please sign in to comment.