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

REPL Await invalidates const #17669

Closed
bmeck opened this issue Dec 14, 2017 · 7 comments
Closed

REPL Await invalidates const #17669

bmeck opened this issue Dec 14, 2017 · 7 comments
Assignees
Labels
doc Issues and PRs related to the documentations. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. known limitation Issues that are identified as known limitations.

Comments

@bmeck
Copy link
Member

bmeck commented Dec 14, 2017

  • Version: HEAD
  • Platform: all
  • Subsystem: repl

The REPL makes const variables not const if await appears in the input:

const x = 1; x = 2; await 0; x
@TimothyGu TimothyGu added the known limitation Issues that are identified as known limitations. label Dec 14, 2017
@TimothyGu
Copy link
Member

Known issue. See #15566:

While this works well for var, it doesn't for top-level let and const (let and const still work as expected in blocks), which will lose their lexical specialness (or constantness) with this approach. However, I simply can't think of any good way to support top-level let and const fully. (Note, DevTools has the same problem; try const a = await Promise.resolve(1); back-to-back multiple times.) If you've got an idea, please comment!

The RFC at the end is still active!

@bmeck
Copy link
Member Author

bmeck commented Dec 14, 2017

working on fix in https://github.com/bmeck/node/tree/env-record-repl-await , also fixes some other bugs

@Trott
Copy link
Member

Trott commented Feb 6, 2019

I'm unable to replicate this. Any chance this never went out in a release without a subsequent fix? Should this be closed? Or am I just testing wrong somehow?

@Trott
Copy link
Member

Trott commented Feb 6, 2019

Ah, never mind, I see I need to use the --experimental-repl-await flag. Seeing the bug now.

@damianobarbati
Copy link

@Trott is the --experimental-repl-await flag supposed to work now?
Because I can't have the --experimental-repl-await working properly.

$ node --experimental-modules --experimental-repl-await src/login.js
(node:484) ExperimentalWarning: The ESM module loader is experimental.
file:///opt/src/login.js:8
    const browser = await puppeteer.launch({
                    ^^^^^

SyntaxError: Unexpected reserved word
    at Loader.moduleStrategy (internal/modules/esm/translators.js:84:18)
    at async link (internal/modules/esm/module_job.js:36:21)

@devsnek
Copy link
Member

devsnek commented Feb 13, 2020

--experimental-repl-await only enables top-level await within the repl (that's why it has repl in the name).

@damianobarbati
Copy link

Oh so there's no way to have top level-await in a script now, correct?

@jasnell jasnell added doc Issues and PRs related to the documentations. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. labels Jun 26, 2020
jasnell added a commit to jasnell/node that referenced this issue Apr 28, 2021
targos pushed a commit that referenced this issue Apr 29, 2021
Fixes: #17669
Signed-off-by: James M Snell <[email protected]>

PR-URL: #38449
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
targos pushed a commit that referenced this issue May 30, 2021
Fixes: #17669
Signed-off-by: James M Snell <[email protected]>

PR-URL: #38449
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
targos pushed a commit that referenced this issue Jun 5, 2021
Fixes: #17669
Signed-off-by: James M Snell <[email protected]>

PR-URL: #38449
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
targos pushed a commit that referenced this issue Jun 5, 2021
Fixes: #17669
Signed-off-by: James M Snell <[email protected]>

PR-URL: #38449
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
targos pushed a commit that referenced this issue Jun 11, 2021
Fixes: #17669
Signed-off-by: James M Snell <[email protected]>

PR-URL: #38449
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
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. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. known limitation Issues that are identified as known limitations.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants
@bmeck @jasnell @Trott @TimothyGu @damianobarbati @devsnek and others