Closed Bug 509040 Opened 10 years ago Closed 10 years ago

DEFSHARP should define, not set, properties on fp->sharpArray

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect
Not set

Tracking

()

RESOLVED FIXED

People

(Reporter: jorendorff, Assigned: jorendorff)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file)

Array.prototype.__defineSetter__(5000, function () { throw "FIT"; });
  var x = ({a:#5000={},b:#5000#});

This shouldn't call the setter.


Bug 479630 partly masks this bug: currently the setter isn't called if the array happens to be filled up in such a way that it remains dense. The above test works around this by starting with #5000, which makes the array sparse. But note that uneval() can create expressions that do this too:

  js> uneval(#0={a:#1=[#1#], b:#2=[#2#],c:#0#})
  #3={a:#1=[#1#], b:#2=[#2#], c:#3#}   // note sharp-ids not sequential


Here is an extra sanity test that this fix doesn't break reuse of a sharp-variable (pretty sketchy feature, if you ask me):

  assertEq(uneval(#1={a:#1#,b:#1={c:#1#}}),
           uneval(#1={a:#1#,b:#2={c:#2#}}));

We might already have a test for that.
Attached patch v1Splinter Review
Assignee: general → jorendorff
Attachment #393193 - Flags: review?(brendan)
Attachment #393193 - Flags: review?(brendan) → review+
http://hg.mozilla.org/tracemonkey/rev/d2362511eaa9
Whiteboard: fixed-in-tracemonkey
Sigh, this change doesn't fix the test case, thanks to bug 509047. But that will be fixed shortly, I hope...
http://hg.mozilla.org/mozilla-central/rev/d2362511eaa9
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Flags: wanted1.9.2+
You need to log in before you can comment on or make changes to this bug.