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 cannot compile a getter with try-catch that always returns #1056

Open
anton-trunov opened this issue Jul 12, 2024 · 2 comments
Open

FunC cannot compile a getter with try-catch that always returns #1056

anton-trunov opened this issue Jul 12, 2024 · 2 comments

Comments

@anton-trunov
Copy link

Consider the following FunC contract:

#pragma version =0.4.4;
#pragma allow-post-modification;
#pragma compute-asm-ltr;

_ %testTryCatch() method_id(130441) {
    try {
        throw(1042);
    } catch (_, $e) {
        return $e;
    }
}

() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure {
    throw(130);
}

Compilation succeeds.

I get the following compilation error:

test.fc:11:1: error: previous function return type int cannot be unified with implicit end-of-block return type (): cannot unify type () with int
  }
  ^
$ ./func-mac-arm64 test.fc

I'm using this version of FunC: https://github.com/ton-blockchain/ton/releases/download/v2024.06/func-mac-arm64

If I add an unreachable return statement, compilation succeeds:

#pragma version =0.4.4;
#pragma allow-post-modification;
#pragma compute-asm-ltr;

_ %testTryCatch() method_id(130441) {
    try {
        throw(1042);
    } catch (_, $e) {
        return $e;
    }
    return 239;  ;;  <-- added unreachable code
}

() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure {
    throw(130);
}
@Sshahramahmadi

This comment was marked as spam.

@Arpon307

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants