Add explicit ToNumber in wrappedCompareFn in TypedArraySort

RESOLVED FIXED in Firefox 63

Status

()

defect
P2
normal
RESOLVED FIXED
a year ago
8 months ago

People

(Reporter: anba, Assigned: khyperia)

Tracking

(Blocks 1 bug)

Trunk
mozilla63
Points:
---

Firefox Tracking Flags

(firefox61 wontfix, firefox62 wontfix, firefox63 fixed)

Details

Attachments

(1 attachment)

(Reporter)

Description

a year ago
https://searchfox.org/mozilla-central/rev/36dec78aecc40539ecc8d78e91612e38810f963c/js/src/builtin/TypedArray.js#1213
---
// Step a.
var v = comparefn(x, y);
---

should instead read:

---
// Step a.
var v = +comparefn(x, y);
---



Test case:
---
var ta = new Int32Array(4);
var ab = ta.buffer;

ta.sort(function(a, b) {
  print("COMPARE");
  detachArrayBuffer(ab);
  return {
    [Symbol.toPrimitive]() { print("TO_PRIMITIVE"); }
  };
});
---

Expected: Prints "COMPARE" and "TO_PRIMITIVE"
Actual: Prints only "COMPARE"
Priority: -- → P1
(Reporter)

Updated

a year ago
Blocks: 1291005
Priority: P1 → P2
(Assignee)

Updated

8 months ago
Assignee: nobody → khyperia
Status: NEW → ASSIGNED
(Assignee)

Updated

8 months ago
Attachment #9002825 - Flags: review?(jdemooij)
Comment on attachment 9002825 [details] [diff] [review]
Add explicit ToNumber in wrappedCompareFn in TypedArraySort.

Review of attachment 9002825 [details] [diff] [review]:
-----------------------------------------------------------------

Stealing review.

r=me, but this test belongs in test262. Now is a good time to figure out js/src/tests/test262-export.py.
Attachment #9002825 - Flags: review?(jdemooij) → review+
(Assignee)

Updated

8 months ago
Keywords: checkin-needed

Comment 3

8 months ago
Pushed by csabou@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/4e65beb5c226
Add explicit ToNumber in wrappedCompareFn in TypedArraySort. r=jorendorff
Keywords: checkin-needed

Comment 4

8 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/4e65beb5c226
Status: ASSIGNED → RESOLVED
Last Resolved: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.