Adding public fields to an object can be side-effectful and should be marked as such.
Categories
(DevTools :: Console, defect, P2)
Tracking
(Not tracked)
People
(Reporter: mgaudet, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
101.69 KB,
image/png
|
Details |
+++ This bug was initially created as a clone of Bug #1651420 +++
Adding a public field to an object can be side-effectful and should block instant-evaluation.
Assuming you have already executed this in the console:
class Base {
constructor(o) { return o; }
};
class A extends Base {
x = 14
}
var obj = {};
Then typing new A(obj)
should not be evaluated, as it would mutate obj
, adding the property x
to it.
Reporter | ||
Comment 1•4 years ago
•
|
||
The Private fields version of this (Bug 1651420) is easy enough to fix, because we can add the opcode InitPrivateElem
to the deny list, dust off our hands and walk away.
I'm less sure about what to do in the public fields case... cursory inspection suggests we use InitProp
, but it's not clear if it's acceptable to disable instant evaluation for InitProp
, which I have to imagine is used elsewhere.
Oh, and then I have to imagine there's also the even more gross version of this (not tested, just realized tho):
class Base {
constructor(o) { return o; }
};
var x = 'hihi';
class A extends Base {
[x] = 14
}
var obj = {};
which would use InitElem
Updated•4 years ago
|
Description
•