Closed Bug 1651420 Opened 4 years ago Closed 4 years ago

Adding private fields to an object is side-effectful and should be marked as such.

Categories

(DevTools :: Console, defect)

defect

Tracking

(firefox80 fixed)

RESOLVED FIXED
Firefox 80
Tracking Status
firefox80 --- fixed

People

(Reporter: mgaudet, Assigned: mgaudet)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Adding a private field to an object is 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 
} 
var obj = {}; 

Then typing new A(obj) should not be evaluated, as it would mutate obj. Then subsequently, if you hit enter, it would issue an error as the object would already have the field, which is a TypeError with private Fields.

Note: Until private fields are enabled by default, this test case will take the
early return. However, I have tested locally that it fails without the fix, and
passes with the fix.

Assignee: nobody → mgaudet
Status: NEW → ASSIGNED
Pushed by mgaudet@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5db8d39515b3 Adding private fields to an object is side-effectful and should be marked as such r=loganfsmyth
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 80
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: