Open Bug 1580891 Opened 5 years ago Updated 1 month ago

Console expressions should allow let/const variables and classes to be redeclared

Categories

(DevTools :: Console, enhancement, P3)

enhancement

Tracking

(Not tracked)

ASSIGNED

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.

Priority: -- → P1
Summary: Console expressions should allow variables to be redeclared → Console expressions should allow let/const variables and classes to be redeclared

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.

Flags: needinfo?(ystartsev)
Flags: needinfo?(loganfsmyth)
Flags: needinfo?(jorendorff)
Flags: needinfo?(jimb)
Flags: needinfo?(bhackett1024)

See also bug 1257088.

See Also: → 1257088

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.

Flags: needinfo?(jimb)

There are two issues here.

  1. Features related to scoping are hard for us because the frontend is a mess. It could be hacked in... Seems bad.

  2. 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.)

Flags: needinfo?(jorendorff)

I don't think I have much I can add here at the moment.

Flags: needinfo?(ystartsev)
Type: defect → enhancement
Priority: P1 → P3
Flags: needinfo?(bhackett1024)

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?

Assignee: nobody → jlaster
Status: NEW → ASSIGNED

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.

Flags: needinfo?(loganfsmyth)
Assignee: jlaster → nobody
Status: ASSIGNED → NEW

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.

I love Firefox but Chrome have this but not FF,

Severity: normal → S3
Duplicate of this bug: 1801567

Jan, do you know if the situation changed in SpiderMonkey since we last looked at this?

Flags: needinfo?(jdemooij)

(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.

Flags: needinfo?(jdemooij)
See Also: → 1801071
See Also: → 1249175
Depends on: 1249175
See Also: 1249175
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Attachment #9092406 - Attachment is obsolete: true
No longer depends on: 1249175
Blocks: 1839588
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: