Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FunC error when wrapping throw inside a function. #904

Open
1 task done
jeshecdom opened this issue Oct 2, 2024 · 1 comment
Open
1 task done

FunC error when wrapping throw inside a function. #904

jeshecdom opened this issue Oct 2, 2024 · 1 comment
Labels
bug Something isn't working or isn't right scope: codegen Code generation, a.k.a. compiler backend

Comments

@jeshecdom
Copy link
Contributor

jeshecdom commented Oct 2, 2024

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

  • I'm using the latest Tact 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

@jeshecdom jeshecdom added the bug Something isn't working or isn't right label Oct 2, 2024
@anton-trunov
Copy link
Member

Seems like this is a related issue: #450

@anton-trunov anton-trunov added the scope: codegen Code generation, a.k.a. compiler backend label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working or isn't right scope: codegen Code generation, a.k.a. compiler backend
Projects
None yet
Development

No branches or pull requests

2 participants