Support object initializer with computed name function in eager evaluation
Categories
(DevTools :: Console, enhancement, P3)
Tracking
(Not tracked)
People
(Reporter: Oriol, Unassigned)
References
(Blocks 1 open bug)
Details
Type this in the console:
({["func"](){}})
Expected: eager evaluation shows Object { func: func() }
Actual: no eager evaluation
({["func"]: ()=>{}})
doesn't work either.
Note these do work:
({func(){}})
({"func"(){}})
({["obj"]: {}})
Comment 1•5 years ago
|
||
This is because of the specifics of the bytecodes used. In this case, arrow functions use SetFunName
to set the function's name after it is created, and we don't allow any sideeffectful opcodes right now, even if you're only mutating an object created in the same piece of eager code. https://searchfox.org/mozilla-central/rev/5a10be606f2d76ef22f1f44565749490de991d35/js/src/debugger/Script.cpp#1490
Updated•5 years ago
|
Reporter | ||
Comment 2•5 years ago
|
||
This is what I suspected. However, from https://searchfox.org/mozilla-central/rev/5a10be606f2d76ef22f1f44565749490de991d35/js/src/vm/Opcodes.h#1586-1602, SetFunName has
Type: Creating functions
And it corresponds to https://tc39.es/ecma262/#sec-setfunctionname, which says:
Assert: F is an extensible object that does not have a "name" own property.
So more than changing an existing object it seems it's initializing a just created one.
Then it seems safe to allow it?
Comment 3•5 years ago
|
||
You're right, since that opcode is only used on functions that have just been created, we could technically allow it with no issues.
Updated•3 years ago
|
Description
•