diff --git a/src/objects/bigint.cc b/src/objects/bigint.cc index df3f798f29..49a8728f15 100644 --- a/src/objects/bigint.cc +++ b/src/objects/bigint.cc @@ -2261,9 +2261,8 @@ MaybeHandle BigInt::AsUintN(Isolate* isolate, uint64_t n, int needed_length = static_cast((n + kDigitBits - 1) / kDigitBits); if (x->length() < needed_length) return x; int bits_in_top_digit = n % kDigitBits; - if (bits_in_top_digit == 0) { - if (x->length() == needed_length) return x; - } else { + if (x->length() == needed_length) { + if (bits_in_top_digit == 0) return x; digit_t top_digit = x->digit(needed_length - 1); if ((top_digit >> bits_in_top_digit) == 0) return x; } diff --git a/test/mjsunit/harmony/bigint/as-int-n.js b/test/mjsunit/harmony/bigint/as-int-n.js index ef48cadcc6..ccb7c79f93 100644 --- a/test/mjsunit/harmony/bigint/as-int-n.js +++ b/test/mjsunit/harmony/bigint/as-int-n.js @@ -297,4 +297,8 @@ }{ assertThrows(() => BigInt.asUintN(3, 12), TypeError); assertEquals(4n, BigInt.asUintN(3, "12")); +}{ + // crbug.com/936506 + assertEquals(1n, BigInt.asUintN(15, 0x100000001n)); + assertEquals(1n, BigInt.asUintN(15, 0x10000000000000001n)); }