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: Defining a variable with let with erroneous input says it is not defined. On defining it, throws an error saying it has already been defined. #32288

Closed
13thThief opened this issue Mar 15, 2020 · 5 comments
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. repl Issues and PRs related to the REPL subsystem.

Comments

@13thThief
Copy link

  • Version: 12.x
  • System: Linux Ubuntu x86_64 5.3.0-40-generic
  • Subsystem: REPL

What steps will reproduce the bug?

Define a variable test with something that will throw an error. On printing test, test is not defined, So let test = <something that doesn't throw an error>. Throws an error test has already been defined.

let test = new Date(k);
Thrown:
ReferenceError: k is not defined
test
Thrown:
ReferenceError: test is not defined
let test = 4;
Thrown:
SyntaxError: Identifier 'test' has already been declared

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

All the time. Required condition it to define the variable with let and erroneous data or something that is not defined.

What is the expected behavior?

Should be able to define test variable if it is not defined

What do you see instead?

test has already been defined and test is not defined

@devsnek
Copy link
Member

devsnek commented Mar 15, 2020

Duplicate of #8441 #8376 #8309 #16520 #14092

@devsnek devsnek closed this as completed Mar 15, 2020
@devsnek devsnek added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Mar 15, 2020
@BridgeAR
Copy link
Member

V8 did implement a "REPL" mode for the inspector but it only supports let so far. const is still not working as expected. To make use of that mode we'll have to implement the functionality in a couple of places (at least that's how it looked like when I checked). It'll take some more time until this is fixed.

@devsnek
Copy link
Member

devsnek commented Mar 15, 2020

I've been tracking that too :) It works locally in my prototype repl, but mainline node needs to wait for v8 8.1 to be merged (and then needs to move to Runtime.evaluate)

@gireeshpunathil
Copy link
Member

can we re-open this, as a tracking issue, if there is an intent to fix this?
on the other hand if we stand on working as designed, let us tag it as wontfix?

Right now we seem to be sitting on both sides.

My take is to keep it open. Despite being spec compliant, the confusion is natural and genuine, and the number of issues on this is a proof of poor user experience on variable definition semantics

@devsnek
Copy link
Member

devsnek commented Mar 16, 2020

@gireeshpunathil sgtm, i'd just say open the oldest one so all the dupes funnel into it

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

5 participants