Skip to content

unwrap_or_else((_) => Vec.new()) crashes codegen: "BUG: closure result lacks LLVM type" #1378

Closed

Description

@ehartford

Spec: §10 (Result/Option eliminators: unwrap_or_else[U]((fn(E) -> U)) -> Join[T, U]).

Found while building the #1363 matrix.

fn rv(ok: bool) -> Result[Vec[i32], str]:
    if not ok: return Err("no" ++ "pe")
    Ok(Vec.new())
fn main:
    let t = rv(false).unwrap_or_else((_) => Vec.new())
    print(t.len())

Actual (installed v0.15.2.1 and origin/main 8c859a7): BUG: closure result lacks LLVM type: node=7633 [src/CodegenDispatch.w:17259 Codegen.gen_closure], rc=134. Same for Option (() => Vec.new()). An owned local default ((_) => d) and a str literal ((_) => "") compile.

Expected: 0. The closure result type is forced by the join (Vec[i32]), so Vec.new() needs no annotation.

Workaround: none used; the #1363 matrix excludes the unwrap_or_else × Vec × literal-default cells.

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