diff --git a/lib/internal/repl/await.js b/lib/internal/repl/await.js index e0b79805df049b..2f3e754b5d5d21 100644 --- a/lib/internal/repl/await.js +++ b/lib/internal/repl/await.js @@ -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}=`); }, diff --git a/test/parallel/test-repl-top-level-await.js b/test/parallel/test-repl-top-level-await.js index 9194c4a449007f..c6717a2120f45c 100644 --- a/test/parallel/test-repl-top-level-await.js +++ b/test/parallel/test-repl-top-level-await.js @@ -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) {