mirror of https://github.com/nodejs/node.git
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
parent
0fd55e71fe
commit
35f9cd22f5
|
@ -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}=`);
|
||||
},
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue