diff --git a/doc/api/repl.md b/doc/api/repl.md index 1d216c4358fcd4..32be32946d5107 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -235,8 +235,7 @@ undefined ``` One known limitation of using the `await` keyword in the REPL is that -it will invalidate the lexical scoping of the `const` and `let` -keywords. +it will invalidate the lexical scoping of the `const` keywords. For example: @@ -245,9 +244,7 @@ For example: undefined > m 123 -> const m = await Promise.resolve(234) -undefined -> m +> m = await Promise.resolve(234) 234 ``` diff --git a/test/parallel/test-repl-top-level-await.js b/test/parallel/test-repl-top-level-await.js index 1abcca75f1e2a0..f34617679f3789 100644 --- a/test/parallel/test-repl-top-level-await.js +++ b/test/parallel/test-repl-top-level-await.js @@ -173,6 +173,10 @@ async function ordinaryTests() { '3', 'undefined', ]], + ['const k = await Promise.resolve(123)'], + ['k', '123'], + ['k = await Promise.resolve(234)', '234'], + ['k', '234'], // Regression test for https://github.com/nodejs/node/issues/43777. ['await Promise.resolve(123), Promise.resolve(456)', 'Promise {', { line: 0 }], ['await Promise.resolve(123), await Promise.resolve(456)', '456'],