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: nodejs#23841
Fixes: nodejs#23836
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
codebytere authored and MylesBorins committed Mar 20, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 26288c8 commit b9188d4
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
@@ -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}=`);
},
3 changes: 2 additions & 1 deletion test/parallel/test-repl-top-level-await.js
Original file line number Diff line number Diff line change
@@ -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) {

0 comments on commit b9188d4

Please sign in to comment.