Open Bug 1651421 Opened 4 years ago Updated 4 years ago

Adding public fields to an object can be side-effectful and should be marked as such.

Categories

(DevTools :: Console, defect, P2)

defect

Tracking

(Not tracked)

People

(Reporter: mgaudet, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

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

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

Severity: -- → S3
Priority: -- → P2
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: