repl: support top-level for-await-of

PR-URL: https://github.com/nodejs/node/pull/23841
Fixes: https://github.com/nodejs/node/issues/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>
pull/23938/head
Shelley Vohr 2018-10-23 22:34:03 -07:00 committed by Michaël Zasso
parent 0fd55e71fe
commit 35f9cd22f5
No known key found for this signature in database
GPG Key ID: 770F7A9A5AE15600
2 changed files with 8 additions and 1 deletions

View File

@ -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}=`);
},

View File

@ -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) {