Skip to content

Commit 02f13ab

Browse files
codebyteretargos
authored andcommitted
repl: support top-level for-await-of
PR-URL: #23841 Fixes: #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>
1 parent dcaf723 commit 02f13ab

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/internal/repl/await.js

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ const visitorsWithoutAncestors = {
1111
}
1212
walk.base.ClassDeclaration(node, state, c);
1313
},
14+
ForOfStatement(node, state, c) {
15+
if (node.await === true) {
16+
state.containsAwait = true;
17+
}
18+
walk.base.ForOfStatement(node, state, c);
19+
},
1420
FunctionDeclaration(node, state, c) {
1521
state.prepend(node, `${node.id.name}=`);
1622
},

test/parallel/test-repl-top-level-await.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ async function ordinaryTests() {
130130
[ 'let o = await 1, p', 'undefined' ],
131131
[ 'p', 'undefined' ],
132132
[ 'let q = 1, s = await 2', 'undefined' ],
133-
[ 's', '2' ]
133+
[ 's', '2' ],
134+
[ 'for await (let i of [1,2,3]) console.log(i)', 'undefined', { line: 3 } ]
134135
];
135136

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

0 commit comments

Comments
 (0)