Open AidPaike opened 1 year ago
Thanks for reporting, the issue is valid. The latest spec clarifies that NaN return value of the comparefn should be changed to +0. JerryScript hasn't implemented the latest spec yet, but it seems to be easily fixable. I'm going to fix it soon.
Version
Version: 3.0.0 ( 6fe763f )
Testcase1
Execution steps
/root/.jsvu/jerry Testcase.js
Output
Expected behavior
Testcase2
Output
Expected behavior
Description
When executing this Testcase, I mistakenly wrote
a.value
toa.avalue
in line 4, which caused all the return values ofparts.sort
to becomeNaN
. At this point, none of the other engines changed the ordering of the original array, butjerryscript
seems treat NaN as +0. Reference (https://tc39.es/ecma262/#sec-array.prototype.sort)The same bug has reported to SpiderMonkey (https://bugzilla.mozilla.org/show_bug.cgi?id=1763996) and has been fixed.
Looking forward to your reply :)