Skip to content

ICE when having return with mismatched type in arrays #7363

@ironcev

Description

@ironcev

E.g., the below script will fail with:

Internal compiler error: Verification failed: Function in_array_2 return type must match its RET instructions.
script;

fn in_array() -> u64 {
    let _ = [return, return];
    42
}

fn in_length_1_array() -> u64 {
    let _ = [return];
    42
}

fn in_length_2_array_first() -> u64 {
    let _ = [return, 0];
    42
}

fn in_length_2_array_second() -> u64 {
    let _ = [0, return];
    42
}

fn main() {
    let _ = in_array();
    let _ = in_length_1_array();
    let _ = in_length_2_array_first();
    let _ = in_length_2_array_second();
}

The ICE appears also if we return any mismatched type. E.g., having everywhere return true.

The expected behavior is the one we have in the should_fail/return_in_non_statement_positions test - type mismatched error should be emitted.

The should_fail/return_in_non_statement_positions is currently disabled. This is very likely the reason we didn't spot this issue before. That test is being adapted and will be enabled in the upcoming PR that finalizes #7276.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompilerGeneral compiler. Should eventually become more specific as the issue is triagedteam:compilerCompiler Team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions