1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

LibJS: Avoid FormatNumericToString spec issue more carefully

This becomes more of an issue when implementing the Intl mathematical
value, where negative zero is treated as a special enum value. In that
case, we already previously changed the value from -0 to +0 in step 1b.
Entering the branch for step 4 will then set it back to -0.

The math that follows after these steps worked fine with both +0/-0, but
assertions will be reached in the Intl MV implementation.
This commit is contained in:
Timothy Flynn 2022-07-19 09:59:34 -04:00 committed by Linus Groh
parent 042dfc7284
commit 20533c2594

View file

@ -552,11 +552,11 @@ FormatResult format_numeric_to_string(GlobalObject& global_object, NumberFormatB
// 3. If x < 0, let isNegative be true; else let isNegative be false.
// FIXME: Spec issue: this step would override step 1a, see https://github.com/tc39/proposal-intl-numberformat-v3/issues/67
is_negative |= is_less_than_zero(number);
if (is_less_than_zero(number)) {
is_negative = true;
// 4. If isNegative, then
if (is_negative) {
// a. Let x be -x.
// 4. If isNegative, then
// a. Let x be -x.
number = multiply(global_object, number, -1);
}