Skip to content

A call through a let-alias of a non-Copy fn field (let r = c.run; r(21)) lowers as a call to a function NAMED r with the argument dropped — FATAL unhandled GENERIC_CALL; broke the build runner (build/corpora.w:74) #1635

Closed

Description

@ehartford

Main 4932b8bd (D62/D63: fn(A) -> R is not Copy). Repro:

type Corp { name: str, run: fn(i32) -> i32 }
fn dbl(x: i32) -> i32: x * 2
fn go(c: &Corp) -> i32:
    let r = c.run
    r(21)
fn main:
    let owned = Corp { name: "a", run: dbl }
    print(go(&owned))

Pinned seed: 42. Main: FATAL: unhandled MirIntrinsic.GENERIC_CALL sym=r node_kind=27 recv_ty=0 recv_kind=-1 arg_count=0 / error: code generation failed. Same for an owned c, any binding name, a statement in between. Works: c.run(21), let r = &c.run; r(21), let r = c.run.clone(); r(21), and the same alias for a str field.

Pinned so far (lldb on the tree's stage1): Sema correctly treats r as a view binding of the field (D22 §13.6 errors fire for var/typed/consuming uses); MirLower lower_let_binding takes the alias path (bind_alias_place(r, place 2), no local); the call's ident-callee dispatch in lower_expr (~src/MirLower.w:14943+) never calls lookup_alias_place(r) (breakpoint never hit), calls lookup_local(r) once (-1) and generic_fn_node_for_sym(r), and emits call const fn <sym r>() — --dump-mir of go is exactly that, argument dropped. --validate-all says ok over it (silent validator). Consequences: build/corpora.w:74/89/91/93 used this idiom, so the compiler built from main cannot compile the native build runner (with build … falls back to comptime evaluation, which cannot run str.trim → :seed/:seed-driver die); the reseed gate passed anyway (it treated the fallback as a warning). The build-layer sites are being respelled to call through the field (spec-conformant) and the gate is being made to fail on the fallback; this issue is the compiler fix + fixture behav_callable_alias_field_call.w.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions