-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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: Failed assignment "blocks" further assignments to a variable name #6118
Comments
The current behavior is technically semantic, but this is a repl so I agree it is somewhat poor usability. Ideally if you did I'm not actually sure this can be fixed though, because I'm pretty sure it's interpreted to the VM like a script. 😕 |
+1 this has been somewhat of an irritation for me for a while. Just not convinced that it is something that can be fixed in Node.js as I believe it's a v8 issue (Chrome gives precisely the same error). Quick test in the Chrome dev console shows:
|
It originates in v8 I think, but I doubt it is an "issue" on that level, it's just how the language semantics work. Maybe we could give short errors for redeclarations in the REPL along with a more informative message. |
@jasnell In chromium's repl I get a different behavior, than the one I get in node. But it is unexpected non the less:
|
Sigh.. gotta love consistency. +1 to seeing if we can at least improve the errors in REPL. |
This seems to be a side effect of the way Javascript evaluates Without digging too much, it almost seems like a V8 bug to me, but a quick search of the bug tracker doesn't shed any light: https://bugs.chromium.org/p/v8/issues/list?can=1&q=assignment+exception&colspec=ID+Type+Status+Priority+Owner+Summary+HW+OS+Component+Stars&x=priority&y=owner&cells=ids |
Yep, there's actually nothing we can do on this one in Node except maybe make the error a bit more informative. There has been at least one other issue about this reported. Going to close this as it's not something we can fix. |
When running through the `(require ... :reload)` example, I got an error message from Node: SyntaxError: Identifier 'sayHello$$module$src$js$hello' has already been declared at /home/rei/repos/hello-es6/.cljs_node_repl/src/js/hello.js:1:1 at ContextifyScript.Script.runInThisContext (vm.js:26:33) at Object.exports.runInThisContext (vm.js:79:17) at nodeGlobalRequire (repl:85:6) at global.CLOSURE_IMPORT_SCRIPT (repl:75:3) at Object.goog.require (repl:21:8) at repl:1:6 at ContextifyScript.Script.runInThisContext (vm.js:26:33) at Object.exports.runInThisContext (vm.js:79:17) at Domain.<anonymous> ([stdin]:50:34) This was due to the fact that Node (my version is 7.4.0) disallows redefinining anything declared with a `let`. Cf: nodejs/node#6118 This commit replace any `export let` with an `export var` which can be refined without error.
Hi!
On an assignment statement TypeError, using the same variable name is not possible due to either Reference or TypeError when trying to assign a value to a variable with that name.
Steps:
(let|const|var) a = Math.PI()
)let|const|var
OR try to use the variable;Result:
The variable name is no longer available, because you get a
TypeError: Identifier has already been declared
ORReferenceError: variable is not defined
if you try to use the variable nameExpected Behavior:
The variable name to remain undeclared.
Sample Output:
The text was updated successfully, but these errors were encountered: