Skip to content

Calling a fn-typed parameter that returns Result[Unit, E] fails LLVM verification #1230

Closed

Description

@ehartford

Loud, not silent: error: LLVM function verification failed after MIR cleanup for both.

error AgeError = Invalid(age: i32)

fn both(check: fn(i32) -> Result[Unit, AgeError]) -> bool: check(1).is_ok() and check(-1).is_err()

fn strict(age: i32) -> Result[Unit, AgeError]:
    if age < 0: return Err(.Invalid(age))
    Ok(())

fn main:
    print(f"{both(strict)}")

Reproduced on main (installed compiler, 2fd2c59 and later). Not yet root-caused: the next step is the IR of both (with ir), to see which instruction the verifier rejects for the indirect call returning Result[Unit, E].

Blocks: the closure half of the §4.9 fix (a Result[Unit, E] closure body that falls through after an early return Err(...)) cannot be tested until a fn(...) -> Result[Unit, E] value can be called. The function half is fixed and tested in behav_result_unit_falls_through_after_early_err.w; the closure site in SemaCheck.w (~14274) still says "missing return" and should get the same type_is_result_of_unit exemption once this is fixed.

Activity

  1. ehartford commented on Sep 26, 2026

    @ehartford
    ContributorAuthor

    Verified fixed on main 55739d4 (release binary): indirect call returning Result[Unit, E] runs, prints true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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