Fix parsing of newline between 'async' and 'function' (#8698)

This commit is contained in:
Brian Ng
2018-09-16 22:09:23 -05:00
committed by GitHub
parent aa33303112
commit 9b4b436e1f
10 changed files with 285 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
{
"sourceType": "module",
"throws": "Unexpected token, expected \"function\" (1:12)"
"throws": "Unexpected token, expected \"{\" (1:7)"
}

View File

@@ -0,0 +1,2 @@
export default async
function bar() {}

View File

@@ -0,0 +1,3 @@
{
"sourceType": "module"
}

View File

@@ -0,0 +1,119 @@
{
"type": "File",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 17
}
},
"program": {
"type": "Program",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 17
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ExportDefaultDeclaration",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"declaration": {
"type": "Identifier",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
},
"identifierName": "async"
},
"name": "async"
}
},
{
"type": "FunctionDeclaration",
"start": 21,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 17
}
},
"id": {
"type": "Identifier",
"start": 30,
"end": 33,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 12
},
"identifierName": "bar"
},
"name": "bar"
},
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 36,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 17
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
export default async functionX () {}

View File

@@ -0,0 +1,4 @@
{
"sourceType": "module",
"throws": "Unexpected token, expected \"function\" (1:21)"
}

View File

@@ -0,0 +1,2 @@
async
function foo() { }

View File

@@ -0,0 +1,119 @@
{
"type": "File",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"program": {
"type": "Program",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 5
}
},
"expression": {
"type": "Identifier",
"start": 0,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "async"
},
"name": "async"
}
},
{
"type": "FunctionDeclaration",
"start": 6,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"id": {
"type": "Identifier",
"start": 15,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 12
},
"identifierName": "foo"
},
"name": "foo"
},
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 18
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}