From 479b8e5232d10533b7bcb785d19b27a9c423c58f Mon Sep 17 00:00:00 2001 From: Luke Haas Date: Fri, 7 Jun 2024 02:24:32 +0100 Subject: [PATCH] repl: fix await object patterns without values fix lint issue PR-URL: https://github.com/nodejs/node/pull/53331 Reviewed-By: Ruben Bridgewater Reviewed-By: Kohei Ueno --- lib/internal/repl/await.js | 2 +- test/parallel/test-repl-preprocess-top-level-await.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/internal/repl/await.js b/lib/internal/repl/await.js index e4a0d9719d9..9bdb834ff84 100644 --- a/lib/internal/repl/await.js +++ b/lib/internal/repl/await.js @@ -104,7 +104,7 @@ const visitorsWithoutAncestors = { break; case 'ObjectPattern': ArrayPrototypeForEach(node.properties, (property) => { - registerVariableDeclarationIdentifiers(property.value); + registerVariableDeclarationIdentifiers(property.value || property.argument); }); break; case 'ArrayPattern': diff --git a/test/parallel/test-repl-preprocess-top-level-await.js b/test/parallel/test-repl-preprocess-top-level-await.js index bdd1c6fe8a4..c49383e5773 100644 --- a/test/parallel/test-repl-preprocess-top-level-await.js +++ b/test/parallel/test-repl-preprocess-top-level-await.js @@ -144,6 +144,9 @@ const testCases = [ '(async () => { return { value: ((await x).y) } })()'], [ 'await (await x).y', '(async () => { return { value: (await (await x).y) } })()'], + [ 'var { ...rest } = await {}', + 'var rest; (async () => { void ({ ...rest } = await {}) })()', + ], ]; for (const [input, expected] of testCases) {