Console expressions should allow let/const variables and classes to be redeclared
Categories
(DevTools :: Console, enhancement, P3)
Tracking
(Not tracked)
People
(Reporter: jlast, Assigned: nchevobbe)
References
(Blocks 1 open bug)
Details
Attachments
(1 obsolete file)
What were you doing?
At some point we introduced a regression, which prevents expressions from being re-mapped. we should fix this so users can safely declare variables without worrying about redeclaration exceptions.
Reporter | ||
Updated•5 years ago
|
Reporter | ||
Comment 1•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 2•5 years ago
|
||
V8 introduced this feature lately: https://bugs.chromium.org/p/chromium/issues/detail?id=1004193
This handles redeclaration of let
and const
variables, as well as redeclaration of class
, and top-level await.
Our current setup for top-level await works fine, and we can implement a kind of hacky redeclaration of let
and const
declaration by mapping them to self
, but there's no way we can work around the class redeclaration.
I wonder if we could implement a similar REPL mode in SM, or something similar, that could implement things more properly that what we can do from devtools js land.
Pinging a few folks that might know how complex this might be.
Comment 3•5 years ago
|
||
See also bug 1257088.
Comment 4•5 years ago
|
||
This is a good question for front-end people. I'm not familiar with that code any more.
But I definitely like the idea of having SpiderMonkey help us out, rather than pre-processing.
Comment 5•5 years ago
•
|
||
There are two issues here.
-
Features related to scoping are hard for us because the frontend is a mess. It could be hacked in... Seems bad.
-
I heard V8 had a very hard time figuring out exactly what the semantics should be, so ... ideally there would be a clear description of what they did to work from, but I haven't seen that. I guess I could ask devsnek what he thinks of https://github.com/bmeck/js-repl-goal/issues/3. (I can't remember where I heard this, sorry.)
Comment 6•5 years ago
|
||
I don't think I have much I can add here at the moment.
Assignee | ||
Updated•5 years ago
|
Updated•5 years ago
|
Comment 7•5 years ago
|
||
One workaround to unblock this for landing the v0 would be to only enable this in multi-line mode, where snippets with let/const will run into this for repeated execution.
Curious to hear what followers of this bug think?
Updated•5 years ago
|
Comment 8•4 years ago
|
||
I'm gonna clear my NI on this since I don't think there's much I can add without some serious exploration. It really sounds like we should revisit exactly what our expectations are around all of this and then talk to SpiderMonkey folks to see if there's anything that could be done to implement a better eval system for devtools.
Reporter | ||
Updated•4 years ago
|
Comment 9•3 years ago
|
||
I am, of course, missing something terribly tricky here, but if I wrap my multi-line code inside braces it’s a suitable workaround, and I can redeclare anything I like. Isn’t it possible to do something like that?
I know that would limit their scope to the current multi-line session, but possibly a toggle might help here.
Comment 10•2 years ago
|
||
I love Firefox but Chrome have this but not FF,
Updated•2 years ago
|
Assignee | ||
Comment 12•2 years ago
|
||
Jan, do you know if the situation changed in SpiderMonkey since we last looked at this?
Comment 13•2 years ago
|
||
(In reply to Nicolas Chevobbe [:nchevobbe] from comment #12)
Jan, do you know if the situation changed in SpiderMonkey since we last looked at this?
I don't think so. According to comment 2, V8 implemented this with a REPL (parse) mode. That's probably the right way to handle this, but we don't have it yet. It might be nice to add also to support cases like bug 1801071, though. I'll bring this up internally.
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Description
•