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

Weird Behavior of let: letting a variable to itself while defining the variable renders variable as existed #34285

Closed
Power-tile opened this issue Jul 10, 2020 · 7 comments
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs.

Comments

@Power-tile
Copy link

  • Version: 12.12.0
  • Platform: 10.0.18362 Build 18362 Windows 10, 64 bit
  • Subsystem: None, executed in powershell

What steps will reproduce the bug?

$ let a = a; // define a new variable a and assign it with itself, throws ReferenceError
$ a // throws a is not defined
$ let a = 0; // throws Identifier already been declared
$ a // throws a is not defined

Execution process in Powershell:
image

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

I tried several times and they all produce the same result.

What is the expected behavior?

I tried running the same code in the browser, and the let a = 0 statement could successfully define the variable a. Screenshot:
image

What do you see instead?

When executing let a = 0, the environment throws Identifier 'a' already been declared, as shown above.

@Power-tile Power-tile changed the title Weird Behavior of let: letting a variable to itself while defining the variable renders variable as existed Weird Behavior of let: letting a variable to itself while defining the variable renders variable as existed Jul 10, 2020
@devsnek
Copy link
Member

devsnek commented Jul 10, 2020

Duplicate of #34285

@devsnek devsnek marked this as a duplicate of #34285 Jul 10, 2020
@devsnek devsnek closed this as completed Jul 10, 2020
@devsnek devsnek added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Jul 10, 2020
@Power-tile
Copy link
Author

#34825 is this issue. Could you clarify which is the original issue that was duplicated?

@devsnek
Copy link
Member

devsnek commented Jul 10, 2020

oops.

@devsnek
Copy link
Member

devsnek commented Jul 10, 2020

Duplicate of #8309

@devsnek devsnek marked this as a duplicate of #8309 Jul 10, 2020
@Power-tile
Copy link
Author

Thanks for the correction, but after reading #8309 I think these are two different errors. #8309 mentioned that this problem also exists in Chrome console, and I believe the bug was also submitted to Chrome's website. However I tested both on Chrome and Microsoft Edge (which now uses a Chromium core as well), and both of them work as intended:
image
P.S. This image is from Chrome, and the original image in the description of the issue is from Microsoft Edge.

Interestingly, it worked different in Firefox:
image
...which did not throw 'a' is undefined when a is queried.

Therefore I believe this is a different bug. Plz look into this, thanks

@bnoordhuis
Copy link
Member

@Power-tile It's the same bug but Chromium has since migrated to an alternative REPL mode that doesn't have this issue. Node.js will too (probably), someday, once the quirks have been ironed out.

@Power-tile
Copy link
Author

Cool, thanks :D

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

3 participants