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

In REPL after typing "let a=a", variable a is locked and cannot be assigned #37128

Closed
zhanzhenzhen opened this issue Jan 29, 2021 · 3 comments
Closed

Comments

@zhanzhenzhen
Copy link
Contributor

  • Version: 14
  • Platform: Darwin
  • Subsystem: maybe the underlying V8

What steps will reproduce the bug?

In REPL, first type let a=a then type a=1

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

Always

What is the expected behavior?

The first statement causes an error. The second statement doesn't cause an error.

What do you see instead?

Both the first statement and the second statement cause errors.

> let a=a
Uncaught ReferenceError: Cannot access 'a' before initialization
> a=1
Uncaught ReferenceError: Cannot access 'a' before initialization

Additional information

@kaizhu256
Copy link
Contributor

this seems to be v8 issue, as its reproducible in chrome, and differs in behavior wrt to firefox:

// chrome:
let a=a;
// Uncaught ReferenceError: a is not defined
a=1;
// Uncaught ReferenceError: Cannot access 'a' before initialization

// firefox:
let a=a;
// Uncaught ReferenceError: can't access lexical declaration 'a' before initialization
a=1;
1

i don't understand the es-specs @ https://tc39.es/ecma262/#sec-let-and-const-declarations, but maybe someone else could determine whether:

  1. nodejs and chrome violate specs
  2. firefox violate specs
  3. both violate specs
  4. neither violate specs because behavior is undefined

@zhanzhenzhen zhanzhenzhen changed the title After typing "let a=a", variable a cannot be assigned In REPL after typing "let a=a", variable a is locked and cannot be assigned Jan 29, 2021
@Slayer95
Copy link

This is dupe of #8309

@devsnek
Copy link
Member

devsnek commented Jan 29, 2021

Duplicate of #8309

@devsnek devsnek marked this as a duplicate of #8309 Jan 29, 2021
@devsnek devsnek closed this as completed Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants