-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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 crashes after let process; #6802
Comments
The REPL (and node in general) will let you do that but it won't end well. |
But why crash instead of displaying an error as if I typed "let x" two times? |
Interesting.
|
More interesting is that
As @bnoordhuis indicates, I don't think this is an actual bug but it is rather odd. |
cc @nodejs/v8 probably |
That's consistent with The |
Confirmed that this would be fixed by #5703 while going through the open PRs. |
This does not seem like a bug to me.
This creates a @mik-jozef what would you suggest, display an error and then what? There's no way to continue with
As for @addaleax I'm not sure how #5703 would affect this. In fact, all of the examples I've shown in this comment were run on that branch. Can you help me understand what would be different here? |
By not using the global context, you can define a variable named |
@cjihrig ok that makes sense, of course. I'll take a look at the PR and write a test. |
I'm closing this as not-a-bug for now, reopen if you feel that is mistaken. #5703, if/when it lands, should alleviate this gotcha. |
Documentation for REPL states that the default value of `useGlobal` is `false`. It makes no distinction between a REPL that is created programmatically, and the one a user is dropped into on the command line by executing `node` with no arguments. This change ensures that the CLI REPL uses a default value of `false`. Fixes: #5659 Ref: #6802 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> PR-URL: #5703
Documentation for REPL states that the default value of `useGlobal` is `false`. It makes no distinction between a REPL that is created programmatically, and the one a user is dropped into on the command line by executing `node` with no arguments. This change ensures that the CLI REPL uses a default value of `false`. Fixes: #5659 Ref: #6802 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> PR-URL: #5703
#5703 was just reverted, so I'm going to reopen this. @bnoordhuis (or anyone else), if you think this should remain closed, feel free. |
I wonder, if we define process with a const binding in the process it should and not a var binding, basically, kind of like doing: > const _p = process;
undefined
> const process = _p;
undefined
> let process
SyntaxError: Identifier 'process' has already been declared What do you think about fixing this ad-hoc for process? |
I guess the only argument against doing that is that there might be a legitimate reason for someone to modify/overwrite the process object. IDK if there is one. |
@benjamingr Huh? Is that related to this issue? |
@TimothyGu sorry - wrong PR :D |
The possibility kind of sways me from warning to fix this. Just like we don't guard against people modifying |
Maybe the repl could just print a warning if you change any of the built-in objects, e.g.:
We could also in theory have an I'm assuming the issue is people not realising that |
My instinct is to consider this not a bug and leave it as-is. There is no way to recover if the user sets or undefines the global The only reasonable approach, IMO is to define I recommend closing this issue. |
Share `process` through the module wrapper rather than relying on nobody messing with `global.process`. Fixes: nodejs#6802
Share `process` through the module wrapper rather than relying on nobody messing with `global.process`. PR-URL: nodejs#17198 Fixes: nodejs#6802 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Lance Ball <lball@redhat.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Share `process` through the module wrapper rather than relying on nobody messing with `global.process`. Backport-PR-URL: #19006 PR-URL: #17198 Fixes: #6802 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Lance Ball <lball@redhat.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Share `process` through the module wrapper rather than relying on nobody messing with `global.process`. Backport-PR-URL: #19006 PR-URL: #17198 Fixes: #6802 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Lance Ball <lball@redhat.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Share `process` through the module wrapper rather than relying on nobody messing with `global.process`. Backport-PR-URL: #19006 PR-URL: #17198 Fixes: #6802 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Lance Ball <lball@redhat.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Steps to replicate:
Node crashes instead of displaying something like TypeError: Identifier 'process' has already been declared.
The text was updated successfully, but these errors were encountered: