sway icon indicating copy to clipboard operation
sway copied to clipboard

Log decoding fails with `log id missing`

Open kayagokalp opened this issue 1 year ago • 1 comments

#[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

kayagokalp avatar Aug 26 '24 21:08 kayagokalp

My initial guess is that this is because let a = line is a const, and const propagation break log decoding.

kayagokalp avatar Aug 26 '24 21:08 kayagokalp

This repros in the core library tests as well:

cd sway-lib-core/src && forc test ok_abi_encoding --logs --decode

sdankel avatar Sep 09 '24 22:09 sdankel

It looks like this is a problem in libraries because logged_types is always None. Working on a fix.

sdankel avatar Sep 09 '24 23:09 sdankel