Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse
for await (async of ...)
(#13244)
- Loading branch information
Showing
31 changed files
with
554 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ for ((async) of async) async; | |
|
||
for (\u0061sync of []); | ||
|
||
for (async.x of []); | ||
|
||
for (async in []); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ for ((async) of async) async; | |
|
||
for ((async) of []); | ||
|
||
for (async.x of []); | ||
|
||
for (async in []); |
11 changes: 11 additions & 0 deletions
11
packages/babel-generator/test/fixtures/edgecase/for-await-async-of/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
async function f() { | ||
for await (async of []); | ||
|
||
for await (async of async) async; | ||
|
||
for await ((async) of []); | ||
|
||
for await (async.x of []); | ||
|
||
for await (\u0061sync of []); | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/babel-generator/test/fixtures/edgecase/for-await-async-of/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
async function f() { | ||
for await ((async) of []); | ||
|
||
for await ((async) of async) async; | ||
|
||
for await ((async) of []); | ||
|
||
for await (async.x of []); | ||
|
||
for await ((async) of []); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
packages/babel-parser/test/fixtures/es2017/async-functions/export-invalid/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
{ | ||
"sourceType": "module", | ||
"throws": "Unexpected token, expected \"=>\" (1:31)" | ||
} | ||
"sourceType": "module" | ||
} |
46 changes: 46 additions & 0 deletions
46
packages/babel-parser/test/fixtures/es2017/async-functions/export-invalid/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}}, | ||
"errors": [ | ||
"SyntaxError: Missing semicolon. (1:20)", | ||
"SyntaxError: Missing semicolon. (1:33)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}}, | ||
"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": "ExpressionStatement", | ||
"start":21,"end":33,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":33}}, | ||
"expression": { | ||
"type": "CallExpression", | ||
"start":21,"end":33,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":33}}, | ||
"callee": { | ||
"type": "Identifier", | ||
"start":21,"end":30,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":30},"identifierName":"functionX"}, | ||
"name": "functionX" | ||
}, | ||
"arguments": [] | ||
} | ||
}, | ||
{ | ||
"type": "BlockStatement", | ||
"start":34,"end":36,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":36}}, | ||
"body": [], | ||
"directives": [] | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...-parser/test/fixtures/es2018/async-generators/for-await-async-of-arrow-semicolon/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
async function f() { | ||
for await (async of => {};;); | ||
} |
3 changes: 3 additions & 0 deletions
3
...ser/test/fixtures/es2018/async-generators/for-await-async-of-arrow-semicolon/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "Unexpected token (2:6)" | ||
} |
3 changes: 3 additions & 0 deletions
3
...ages/babel-parser/test/fixtures/es2018/async-generators/for-await-async-of-arrow/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
async function f() { | ||
for await (async of => {} of x); | ||
} |
69 changes: 69 additions & 0 deletions
69
...s/babel-parser/test/fixtures/es2018/async-generators/for-await-async-of-arrow/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":57,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, | ||
"errors": [ | ||
"SyntaxError: Invalid left-hand side in for-of statement. (2:13)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":57,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "FunctionDeclaration", | ||
"start":0,"end":57,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16},"identifierName":"f"}, | ||
"name": "f" | ||
}, | ||
"generator": false, | ||
"async": true, | ||
"params": [], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":19,"end":57,"loc":{"start":{"line":1,"column":19},"end":{"line":3,"column":1}}, | ||
"body": [ | ||
{ | ||
"type": "ForOfStatement", | ||
"start":23,"end":55,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":34}}, | ||
"await": true, | ||
"left": { | ||
"type": "ArrowFunctionExpression", | ||
"start":34,"end":48,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":27}}, | ||
"id": null, | ||
"generator": false, | ||
"async": true, | ||
"params": [ | ||
{ | ||
"type": "Identifier", | ||
"start":40,"end":42,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":21},"identifierName":"of"}, | ||
"name": "of" | ||
} | ||
], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":46,"end":48,"loc":{"start":{"line":2,"column":25},"end":{"line":2,"column":27}}, | ||
"body": [], | ||
"directives": [] | ||
} | ||
}, | ||
"right": { | ||
"type": "Identifier", | ||
"start":52,"end":53,"loc":{"start":{"line":2,"column":31},"end":{"line":2,"column":32},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"body": { | ||
"type": "EmptyStatement", | ||
"start":54,"end":55,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":34}} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/es2018/async-generators/for-await-async-of/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
async function f() { | ||
for await (async of x); | ||
} |
51 changes: 51 additions & 0 deletions
51
packages/babel-parser/test/fixtures/es2018/async-generators/for-await-async-of/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":48,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":48,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "FunctionDeclaration", | ||
"start":0,"end":48,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16},"identifierName":"f"}, | ||
"name": "f" | ||
}, | ||
"generator": false, | ||
"async": true, | ||
"params": [], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":19,"end":48,"loc":{"start":{"line":1,"column":19},"end":{"line":3,"column":1}}, | ||
"body": [ | ||
{ | ||
"type": "ForOfStatement", | ||
"start":23,"end":46,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":25}}, | ||
"await": true, | ||
"left": { | ||
"type": "Identifier", | ||
"start":34,"end":39,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":18},"identifierName":"async"}, | ||
"name": "async" | ||
}, | ||
"right": { | ||
"type": "Identifier", | ||
"start":43,"end":44,"loc":{"start":{"line":2,"column":22},"end":{"line":2,"column":23},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"body": { | ||
"type": "EmptyStatement", | ||
"start":45,"end":46,"loc":{"start":{"line":2,"column":24},"end":{"line":2,"column":25}} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/es2021/for-async-of/dot/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
for (async.x of y); |
42 changes: 42 additions & 0 deletions
42
packages/babel-parser/test/fixtures/es2021/for-async-of/dot/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ForOfStatement", | ||
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, | ||
"await": false, | ||
"left": { | ||
"type": "MemberExpression", | ||
"start":5,"end":12,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":12}}, | ||
"object": { | ||
"type": "Identifier", | ||
"start":5,"end":10,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":10},"identifierName":"async"}, | ||
"name": "async" | ||
}, | ||
"computed": false, | ||
"property": { | ||
"type": "Identifier", | ||
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"x"}, | ||
"name": "x" | ||
} | ||
}, | ||
"right": { | ||
"type": "Identifier", | ||
"start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17},"identifierName":"y"}, | ||
"name": "y" | ||
}, | ||
"body": { | ||
"type": "EmptyStatement", | ||
"start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/es2021/for-async-of/escaped/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
for (\u0061sync of x); |
32 changes: 32 additions & 0 deletions
32
packages/babel-parser/test/fixtures/es2021/for-async-of/escaped/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ForOfStatement", | ||
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, | ||
"await": false, | ||
"left": { | ||
"type": "Identifier", | ||
"start":5,"end":15,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":15},"identifierName":"async"}, | ||
"name": "async" | ||
}, | ||
"right": { | ||
"type": "Identifier", | ||
"start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"body": { | ||
"type": "EmptyStatement", | ||
"start":21,"end":22,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":22}} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/es2021/for-async-of/for-statement/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
for (async of => {};;); |
Oops, something went wrong.