Closed Bug 1535471 Opened 7 months ago Closed 6 months ago

Class field initializers need to use JSOP_INITPROP and friends, not JSOP_SETPROP

Categories

(Core :: JavaScript Engine, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox68 --- fixed

People

(Reporter: jorendorff, Assigned: khyperia)

References

Details

Attachments

(1 file)

Initializing properties should never trigger base-class setters, like:

let id = Symbol();

class Base {
  set x(v) { throw new Error("failed"); }
  set [id](v) { throw new Error("failed"); }
}

class X extends Base {
  x = 1;
  [id] = 2;
}

let x = new X();
assertEq(x.x, 1);
assertEq(x[id], 2);

Right now, we're using JSOP_SETPROP in the initializer for the field x; that needs to be JSOP_INITPROP (but check the spec to make sure). Or in the indexed-property or computed-property-name case, JSOP_INITELEM.

Priority: -- → P1
Assignee: nobody → khyperia
Status: NEW → ASSIGNED
Pushed by ahauck@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8457ce7cc442
Use JSOP_INITPROP for field initializers. r=jorendorff
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
Regressions: 1547035
You need to log in before you can comment on or make changes to this bug.