tact-lang / tact

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

Unexpected behaviour using `StateInit` outside of contract context #367

Open 0kenx opened 3 weeks ago

0kenx commented 3 weeks ago
contract B {
    owner: Address;
    init(addr: Address){
        self.owner = addr;
    }
}

fun get_init(addr: Address): StateInit {
    return initOf B(addr);
}

contract A {
    receive("aa") {
        let c: StateInit = get_init(myAddress()); // fails
        // let c: StateInit = initOf B(myAddress()); // succeeds
    }
}

Build succeeds but execution fails with exit code 135: Code of a contract was not found

Moreover, the following also compiles

fun get_init(): StateInit {
    return initOf B(myAddress());
}

but clearly the context of the calling contract is not preserved when calling myAddress() from an external function.