Skip to content

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

Open
@anton-trunov

Description

@anton-trunov

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions