Skip to content

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

@deokjinkim

Description

@deokjinkim

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions