RESOLVED FIXED 188382
Array.prototype.sort should throw TypeError if param is a not callable object
https://bugs.webkit.org/show_bug.cgi?id=188382
Summary Array.prototype.sort should throw TypeError if param is a not callable object
isol2
Reported 2018-08-07 11:50:19 PDT
Hi everyone, According to ES specification (https://tc39.github.io/ecma262/#sec-array.prototype.sort) Array.sort param should be a comparefn or undefined value, otherwise should throw a TypeError. steps to reproduce: var obj = {}; var arr = []; arr.sort(obj); arr.sort(obj, obj); Actual results: pass without failures Expected results: TypeError: The comparison function must be either a function or undefined V8, Chakra and Spidermonkey works as expected.
Attachments
Patch (12.69 KB, patch)
2018-08-08 19:04 PDT, Keith Miller
no flags
isol2
Comment 1 2018-08-07 11:51:15 PDT
OS: Ubuntu 16.04 x64 jsc version: 234654 cinfuzz
Keith Miller
Comment 2 2018-08-08 19:04:47 PDT
WebKit Commit Bot
Comment 3 2018-08-08 20:13:27 PDT
Comment on attachment 346811 [details] Patch Clearing flags on attachment: 346811 Committed r234716: <https://trac.webkit.org/changeset/234716>
WebKit Commit Bot
Comment 4 2018-08-08 20:13:28 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 5 2018-08-08 20:14:18 PDT
Darin Adler
Comment 6 2018-08-19 13:00:28 PDT
Comment on attachment 346811 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=346811&action=review > Source/JavaScriptCore/builtins/ArrayPrototype.js:602 > + @throwTypeError("Array.prototype.sort requires the comparsion function be a function or undefined"); Might also want to fix the typo here: both before and after this patch it says "comparsion" rather than "comparison".
Note You need to log in before you can comment on or make changes to this bug.