You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Platform:
Darwin jMacBook.local 17.7.0 Darwin Kernel Version 17.7.0: Fri Jul 6 19:54:51 PDT 2018; root:xnu-4570.71.3~2/RELEASE_X86_64 x86_64
Subsystem:
REPL
This has been happening a few releases and I am surprised no one has reported (that I could easily find) or fixed it. When declaring a variable with 'let' or 'const' and the literal contains an error, the system will not let me redeclare the variable or use it in an assignment. In the example below, I would have expected the REPL to merely ignore my declaration after giving me the error. I should then be free to redeclare it. However, it will not let me redeclare 'a' nor reference it for an assignment.
EXAMPLE:
jon@jMacBook:wrk$ node -v
v10.7.0
jon@jMacBook:wrk$ node
> let a = a
ReferenceError: a is not defined
> let a = 1
SyntaxError: Identifier 'a' has already been declared
> a = 1
ReferenceError: a is not defined
>
The text was updated successfully, but these errors were encountered:
devsnek
added
duplicate
Issues and PRs that are duplicates of other issues or PRs.
repl
Issues and PRs related to the REPL subsystem.
labels
Aug 7, 2018
Thanks for the information-- Still a bug, but obviously a duplicate. As noted in the dialog, Babbel doesn't have this issue. Looks like its part of v8 as Safari and Chrome have the same behavior but Firefox still allows me to use the declared variable:
No, it's not a bug. The Node.js behavior is correct, according to the ES specification.
What you see in Babel is a Babel issue. What you see in Firefox is a gecko repl extension for devtools console. If you enable warnings in Firefox, you'll see this printed after evaluating your code:
Warning: According to the standard, after the above exception,
Warning: the global bindings should be permanently uninitialized.
Warning: We have non-standard-ly initialized them to `undefined`for you.
Warning: This nicety only happens in the JS shell.
Version:
v10.7.0
Platform:
Darwin jMacBook.local 17.7.0 Darwin Kernel Version 17.7.0: Fri Jul 6 19:54:51 PDT 2018; root:xnu-4570.71.3~2/RELEASE_X86_64 x86_64
Subsystem:
REPL
This has been happening a few releases and I am surprised no one has reported (that I could easily find) or fixed it. When declaring a variable with 'let' or 'const' and the literal contains an error, the system will not let me redeclare the variable or use it in an assignment. In the example below, I would have expected the REPL to merely ignore my declaration after giving me the error. I should then be free to redeclare it. However, it will not let me redeclare 'a' nor reference it for an assignment.
EXAMPLE:
The text was updated successfully, but these errors were encountered: