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 <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 targos committed Nov 1, 2018
1 parent dcaf723 commit 02f13ab
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 02f13ab

Please sign in to comment.