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

Do not assign const variable in error case #20056

Closed
BridgeAR opened this issue Apr 16, 2018 · 6 comments
Closed

Do not assign const variable in error case #20056

BridgeAR opened this issue Apr 16, 2018 · 6 comments
Labels
repl Issues and PRs related to the REPL subsystem. vm Issues and PRs related to the vm subsystem.

Comments

@BridgeAR
Copy link
Member

  • Version: 10.0.0-pre

When using the repl and e.g., writing: const foo = bar() while bar is undefined is going to cause an error. So far so good. The problem is that foo is now assigned even though it would be super nice if that would not be the case due to the error while assigning the variable.

I tried to see how to fix this on my own but it is somewhere in runInContext if I am not mistaken and I have never looked at that part before.

@nodejs/vm @nodejs/repl

@BridgeAR BridgeAR added repl Issues and PRs related to the REPL subsystem. vm Issues and PRs related to the vm subsystem. labels Apr 16, 2018
@TimothyGu
Copy link
Member

Duplicate of #8309, #8376, #8441, and #16520. This is the spec behavior, and there's no way around it.

@vsemozhetbyt
Copy link
Contributor

FWIW, this is also valid for Chrome and Firefox DevTools Console:

c

f

@BridgeAR
Copy link
Member Author

@TimothyGu for me it is not about spec compliance but about a better way to handle it in the repl. So this issue should be about evaluating to diverge from the spec. I am not sure about the current implementation details and if that is even possible.

@devsnek
Copy link
Member

devsnek commented Apr 16, 2018

cc @bmeck your repl proposal makes const not constant right?

@bmeck
Copy link
Member

bmeck commented Apr 16, 2018

Mime keeps const unable to be reassigned, but separate inputs can rebind the variable name to a new binding.

@BridgeAR
Copy link
Member Author

@bmeck for me having const not possible to be reassigned is the worst thing in the repl ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repl Issues and PRs related to the REPL subsystem. vm Issues and PRs related to the vm subsystem.
Projects
None yet
Development

No branches or pull requests

5 participants