LibJS: Add missing spec step to CompareTypedArrayElements

This isn't actually much of an issue because if the LHS side value is -0
and the RHS value is +0, errantly returning 0 in the comparison function
here has the same effect as correctly returning -1. In both cases, the
-0 is left on the LHS.
This commit is contained in:
Timothy Flynn 2022-07-25 09:52:06 -04:00 committed by Linus Groh
parent 864221cb02
commit 56db4235df

View file

@ -412,6 +412,10 @@ ThrowCompletionOr<double> compare_typed_array_elements(GlobalObject& global_obje
: (x.as_double() > y.as_double()))
return 1;
// 8. If x is -0𝔽 and y is +0𝔽, return -1𝔽.
if (x.is_negative_zero() && y.is_positive_zero())
return -1;
// 9. If x is +0𝔽 and y is -0𝔽, return 1𝔽.
if (x.is_positive_zero() && y.is_negative_zero())
return 1;