Skip to content

REPL: when there's error using 'let' to define and initiate variable, that variable is no longer usable #41416

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

Closed
hermit99 opened this issue Jan 6, 2022 · 1 comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs.

Comments

@hermit99
Copy link

hermit99 commented Jan 6, 2022

Version

v17.3.0

Platform

Microsoft Windows NT 10.0.19042.0 x64

Subsystem

No response

What steps will reproduce the bug?

Example1:

let a = x // => Uncaught ReferenceError: x is not defined
a // Uncaught ReferenceError: a is not defined
let a // Uncaught SyntaxError: Identifier 'a' has already been declared

Example2:

let o = { x: 1 }
let a = o.keys() // => Uncaught TypeError: o.keys is not a function
a // Uncaught ReferenceError: a is not defined
let a = Object.keys(o) // Uncaught SyntaxError: Identifier 'a' has already been declared

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

When there are errors during variable initialization, the variable (a) should be undefined

What do you see instead?

Either Uncaught ReferenceError: a is not defined or Uncaught SyntaxError: Identifier 'a' has already been declared, if trying to redefine a

Additional information

Also tested on node.js v16.9.1, same error

@mscdex
Copy link
Contributor

mscdex commented Jan 6, 2022

Duplicate of #8309.

@mscdex mscdex closed this as completed Jan 6, 2022
@mscdex mscdex added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs.
Projects
None yet
Development

No branches or pull requests

2 participants