Fix shifting a negative value when using BigInts (#4429)
When shifting a negative BigInt value if the shift count is very "big" the result should be -1. eg.: ``` (-2n >> (2n*32n)) === -1n ``` Note: the `-2n >> (2n*31n)` already returned `-1n` prior this change. JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
This commit is contained in:
@@ -1412,6 +1412,11 @@ ecma_bigint_shift (ecma_value_t left_value, /**< left BigInt value */
|
||||
{
|
||||
return ecma_bigint_raise_memory_error ();
|
||||
}
|
||||
else if (left_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN)
|
||||
{
|
||||
/* Shifting a negative value with a very big number to the right should be -1. */
|
||||
return ecma_bigint_create_from_digit (1, true);
|
||||
}
|
||||
|
||||
return ECMA_BIGINT_ZERO;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user