fix parser bug where arrow functions have a higher precedence than they should - fixes #2118

This commit is contained in:
Sebastian McKenzie
2015-10-30 22:50:53 +00:00
parent 37159fbc7d
commit 7012116f4e
13 changed files with 119 additions and 8 deletions

View File

@@ -0,0 +1 @@
async () => {}

View File

@@ -0,0 +1,86 @@
{
"type": "File",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"id": null,
"generator": false,
"expression": false,
"async": true,
"params": [],
"body": {
"type": "BlockStatement",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 14
}
},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
async () => {}()

View File

@@ -0,0 +1,3 @@
{
"throws": "Unexpected token (1:14)"
}

View File

@@ -0,0 +1 @@
!()=>0

View File

@@ -0,0 +1,3 @@
{
"throws": "Unexpected token (1:2)"
}

View File

@@ -1 +1 @@
var foo = bar ? (foo) : number => {} : baz;
var foo = bar ? (foo) : number => {} : baz;

View File

@@ -0,0 +1 @@
() => {}()

View File

@@ -0,0 +1,3 @@
{
"throws": "Unexpected token (1:8)"
}