tact-lang / tact

Tact compiler main repository
https://tact-lang.org
MIT License
275 stars 56 forks source link

Tact generates incorrect `__tact_load_address_opt` #370

Closed 0kenx closed 3 weeks ago

0kenx commented 3 weeks ago

When defining

message MsgA {
    x: Int as uint8;
    y: Address?;
    z: Int as uint16;
}

Tact generates the following code in *.stdlib.fc

(slice, slice) __tact_load_address_opt(slice cs) inline {
    slice raw = cs~load_msg_addr();
    if (raw.preload_uint(2) != 0) {
        return (cs, __tact_verify_address(raw));
    } else {
        return (cs, null());
    }
}

It should skip 2 bits in the else branch before returning.