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

TypeError yields unusable variable #32504

Closed
john-aws opened this issue Mar 26, 2020 · 2 comments
Closed

TypeError yields unusable variable #32504

john-aws opened this issue Mar 26, 2020 · 2 comments
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. repl Issues and PRs related to the REPL subsystem.

Comments

@john-aws
Copy link

  • Version: v12.16.1
  • Platform: OS X 10.14.6
  • Subsystem:

What steps will reproduce the bug?

$ node
Welcome to Node.js v12.16.1.
Type ".help" for more information.
> let m = Map();
Uncaught TypeError: Constructor Map requires 'new'
    at Map (<anonymous>)
> m
Uncaught ReferenceError: m is not defined
> let m = new Map();
Uncaught SyntaxError: Identifier 'm' has already been declared
> m = new Map();
Uncaught ReferenceError: m is not defined
> delete m
false
> m = 2
Uncaught ReferenceError: m is not defined

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

100%

What is the expected behavior?

It appears that m is declared, but not defined. Why am I unable to initialize it at this point using m = 2 or m = new Map()?

@addaleax addaleax added duplicate Issues and PRs that are duplicates of other issues or PRs. repl Issues and PRs related to the REPL subsystem. labels Mar 26, 2020
@addaleax
Copy link
Member

Duplicate of #8441 #8376 #8309 #16520 #14092 #32288 (and probably more) – basically, this is how the JS spec works, unfortunately.

V8 is working on a REPL mode that is going to allow us to work around this issue, see the comments in #32288 for more details.

@john-aws
Copy link
Author

Thank you for the speedy response. I totally sympathize with you and the team when it comes to implementing the dark corners of the language spec and thanks for all your efforts.

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. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants