Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lexical scoping of the const is not invalidated when use await in REPL #45918

Open
deokjinkim opened this issue Dec 20, 2022 · 0 comments · May be fixed by #45939
Open

Lexical scoping of the const is not invalidated when use await in REPL #45918

deokjinkim opened this issue Dec 20, 2022 · 0 comments · May be fixed by #45939
Labels
doc Issues and PRs related to the documentations.

Comments

@deokjinkim
Copy link
Contributor

deokjinkim commented Dec 20, 2022

Affected URL(s)

https://github.com/nodejs/node/blob/main/doc/api/repl.md#await-keyword

Description of the problem

In document, described as below.

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.

For example:

> const m = await Promise.resolve(123)
undefined
> m
123
> const m = await Promise.resolve(234)
undefined
> m
234

But actual result is different like below.
(1) const

Welcome to Node.js v20.0.0-pre.
Type ".help" for more information.
> const m = await Promise.resolve(123)
undefined
> m
123
> const m = await Promise.resolve(234)
Uncaught SyntaxError: Identifier 'm' has already been declared
>

(2) let

Welcome to Node.js v20.0.0-pre.
Type ".help" for more information.
> let m = await Promise.resolve(123)
undefined
> m
123
> let m = await Promise.resolve(234)
Uncaught SyntaxError: Identifier 'm' has already been declared
>

I guess limitation is fixed. So how about removing these lines(One known blabla, including example) from document?

@deokjinkim deokjinkim added the doc Issues and PRs related to the documentations. label Dec 20, 2022
@deokjinkim deokjinkim linked a pull request Dec 21, 2022 that will close this issue
abhishekumar-tyagi pushed a commit to abhishekumar-tyagi/node that referenced this issue May 5, 2024
Invalidating the lexical scoping of the `const` and
`let` keywords is fixed.

Fixes: nodejs/node#45918
abhishekumar-tyagi pushed a commit to abhishekumar-tyagi/node that referenced this issue May 5, 2024
Lexical scope of `const` is only invalidated when
using top-level `await` in REPL.

Fixes: nodejs/node#45918
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant