tact-lang / tact

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

FunC error when wrapping `throw` inside a function. #904

Open jeshecdom opened 1 month ago

jeshecdom commented 1 month ago

Are you using the latest released (or pre-released, a.k.a. "next") version?

Tact source code

// The same happens if Bool is changed for Int

fun throwException(): Bool {   
    throw(4);
}

contract Test {

    get fun testGetter(): Bool {
        return throwException();
    }
}

Relevant Tact/build system log output

> Test: func compiler
Func compilation error: /.../test_Test.code.fc:20:1: error: previous function return type int 
cannot be unified with implicit end-of-block return type (): cannot unify type () with int.

The relevant generated FunC code is this:

int $global_throwException() impure inline_ref {
    throw(4);
}

(tuple, int) $Test$_fun_testGetter(tuple $self) impure inline_ref {
    var ($self) = $self;
    var $fresh$ret_0 = $global_throwException();
    return ($self, $fresh$ret_0);
}

What happened?

In the FunC code, is the error saying that the implicit return type () in function $global_throwException() does not match its return type, which is int?

What did you expect?

No compilation error.

Steps to reproduce

No response

How do you run Tact?

No response

Anything else?

No response

anton-trunov commented 1 month ago

Seems like this is a related issue: #450