mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Num.powInt: panic on overflow
This commit is contained in:
parent
364249a29d
commit
6dfa458e6c
3 changed files with 28 additions and 19 deletions
|
@ -1829,24 +1829,12 @@ impl<'a> LowLevelCall<'a> {
|
|||
_ => panic_ret_type(),
|
||||
}
|
||||
}
|
||||
NumPowInt => {
|
||||
self.load_args(backend);
|
||||
let base_type = CodeGenNumType::for_symbol(backend, self.arguments[0]);
|
||||
let exponent_type = CodeGenNumType::for_symbol(backend, self.arguments[1]);
|
||||
let ret_type = CodeGenNumType::from(self.ret_layout);
|
||||
|
||||
debug_assert!(base_type == exponent_type);
|
||||
debug_assert!(exponent_type == ret_type);
|
||||
|
||||
let width = match ret_type {
|
||||
CodeGenNumType::I32 => IntWidth::I32,
|
||||
CodeGenNumType::I64 => IntWidth::I64,
|
||||
CodeGenNumType::I128 => todo!("{:?} for I128", self.lowlevel),
|
||||
_ => internal_error!("Invalid return type for pow: {:?}", ret_type),
|
||||
};
|
||||
|
||||
self.load_args_and_call_zig(backend, &bitcode::NUM_POW_INT[width])
|
||||
}
|
||||
NumPowInt => match self.ret_layout_raw {
|
||||
LayoutRepr::Builtin(Builtin::Int(width)) => {
|
||||
self.load_args_and_call_zig(backend, &bitcode::NUM_POW_INT[width])
|
||||
}
|
||||
_ => panic_ret_type(),
|
||||
},
|
||||
|
||||
NumIsNan => num_is_nan(backend, self.arguments[0]),
|
||||
NumIsInfinite => num_is_infinite(backend, self.arguments[0]),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue