Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions builtin/int64_js.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ extern "js" fn get_int64_wasm_helper() -> Int64WasmHelper =

///|
impl Div for MyInt64 with div(self : MyInt64, other : MyInt64) -> MyInt64 {
guard not(other.hi == 0 && other.lo == 0) else { panic() }
let exports = get_int64_wasm_helper()
let { hi: ahi, lo: alo } = self
let { hi: bhi, lo: blo } = other
Expand All @@ -131,6 +132,7 @@ impl Div for MyInt64 with div(self : MyInt64, other : MyInt64) -> MyInt64 {

///|
fn MyInt64::div_u(self : MyInt64, other : MyInt64) -> MyInt64 {
guard not(other.hi == 0 && other.lo == 0) else { panic() }
let exports = get_int64_wasm_helper()
let { hi: ahi, lo: alo } = self
let { hi: bhi, lo: blo } = other
Expand All @@ -141,6 +143,7 @@ fn MyInt64::div_u(self : MyInt64, other : MyInt64) -> MyInt64 {

///|
impl Mod for MyInt64 with mod(self : MyInt64, other : MyInt64) -> MyInt64 {
guard not(other.hi == 0 && other.lo == 0) else { panic() }
let exports = get_int64_wasm_helper()
let { hi: ahi, lo: alo } = self
let { hi: bhi, lo: blo } = other
Expand All @@ -151,6 +154,7 @@ impl Mod for MyInt64 with mod(self : MyInt64, other : MyInt64) -> MyInt64 {

///|
fn MyInt64::mod_u(self : MyInt64, other : MyInt64) -> MyInt64 {
guard not(other.hi == 0 && other.lo == 0) else { panic() }
let exports = get_int64_wasm_helper()
let { hi: ahi, lo: alo } = self
let { hi: bhi, lo: blo } = other
Expand Down
36 changes: 36 additions & 0 deletions builtin/int64_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -7472,3 +7472,39 @@ test "grouped test for specific patterns" {
// Test for all bits set except the most significant bit
inspect(UInt64::reinterpret_as_double(0x7FFFFFFFFFFFFFFFUL), content="NaN")
}

///|
#inline(never)
fn int64_zero() -> Int64 {
0L
}

///|
#inline(never)
fn uint64_zero() -> UInt64 {
0UL
}

///|
test "panic 1L / 0L" {
let _ = 1L / int64_zero()

}

///|
test "panic 1L % 0L" {
let _ = 1L % int64_zero()

}

///|
test "panic 1UL / 0UL" {
let _ = 1UL / uint64_zero()

}

///|
test "panic 1UL % 0UL" {
let _ = 1UL % uint64_zero()

}
Loading