From 3d47a267bd17d5f766c9958ec28305c5daf1f597 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 e4a0d9719d9c42..9bdb834ff84fd7 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 bdd1c6fe8a423a..c49383e5773a7b 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) {