Status: Assigned
Owner: [email protected]
Labels: Type-Bug Priority-Medium Harmony

New issue 4125 by [email protected]: Array.prototype.sort doesn't call ToObject on receiver
https://code.google.com/p/v8/issues/detail?id=4125

ES6 specifies that ToObject is called on the receiver before the sort procedure is run https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.sort . However, look at the difference here:

d8> Number.prototype[0] = 5;
5
d8> Number.prototype[1] = 4;
4
d8> Number.prototype.length = 2;
2
d8> x = new Number(0);
0
d8> Array.prototype.sort.call(x)
0
d8> x[0]
4
d8> x[1]
5
d8> Object.getOwnPropertyNames(x)
["0", "1"]

That was all good. However:

d8> Array.prototype.sort.call(0)
(d8):1: illegal access
Array.prototype.sort.call(0)

This would be really easy to fix. Just put a call to TO_OBJECT in the beginning of the ArraySort implementation the way all the other functions in src/arrays.js have.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to