Skip to content

Commit

Permalink
repl: support top-level for-await-of
Browse files Browse the repository at this point in the history
PR-URL: #23841
Fixes: #23836
Reviewed-By: John-David Dalton <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Matheus Marchini <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
codebytere authored and MylesBorins committed Mar 20, 2019
1 parent 26288c8 commit b9188d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/internal/repl/await.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ const visitorsWithoutAncestors = {
}
walk.base.ClassDeclaration(node, state, c);
},
ForOfStatement(node, state, c) {
if (node.await === true) {
state.containsAwait = true;
}
walk.base.ForOfStatement(node, state, c);
},
FunctionDeclaration(node, state, c) {
state.prepend(node, `${node.id.name}=`);
},
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-repl-top-level-await.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ async function ordinaryTests() {
[ 'let o = await 1, p', 'undefined' ],
[ 'p', 'undefined' ],
[ 'let q = 1, s = await 2', 'undefined' ],
[ 's', '2' ]
[ 's', '2' ],
[ 'for await (let i of [1,2,3]) console.log(i)', 'undefined', { line: 3 } ]
];

for (const [input, expected, options = {}] of testCases) {
Expand Down

0 comments on commit b9188d4

Please sign in to comment.