sway
sway copied to clipboard
Log decoding fails with `log id missing`
#[test]
fn math_u16_overflow_mul() {
disable_panic_on_overflow();
let a = (u16::max() / 2 ) + 1;
let b = a * 2;
log(b);
assert(b == 0_u16)
}
#[test]
fn math_u32_overflow_mul() {
disable_panic_on_overflow();
let a = (u32::max() / 2 ) + 1;
let b = a * 2;
log(b);
assert(b == 0_u32)
}
This code fails with error: log id is missing when run with forc test --logs --decode.
Reported by @SwayStar123
My initial guess is that this is because let a = line is a const, and const propagation break log decoding.
This repros in the core library tests as well:
cd sway-lib-core/src && forc test ok_abi_encoding --logs --decode
It looks like this is a problem in libraries because logged_types is always None. Working on a fix.