Issue #1122: types: a generic method’s type parameter is not filled in at the call (NK1103 through a bound, NK1245 on a struct)

Open and answer this issue on GitHub.

ready · opened 2026-11-01 · updated 2026-11-01 · 0 comments

A free generic function fills in R from its argument; the same signature as a method does not. Spec Part I 4.6 fills type parameters from the arguments and ADR-014 names traits with generic methods, so this is a defect, not a gap by design.

Probe 1, works (free function):

fn in_function[R](name: String, run: fn() -> R sync) -> R sync { return run() }
fn main() {
    let a: i64 = in_function(f"f{1}", fn() { return 7 })
    let b: Vec[i64] = in_function(f"g{1}", fn() { return [1, 2] })
    println(f"{a + b.len()}")   // 9
}

Probe 2, method on a struct: NK1245 (it can’t tell the type of host.in_function(...), even with let a: i64):

struct Real { name: String }
impl Real {
    fn in_function[R](self, name: String, run: fn() -> R sync) -> R sync { return run() }
}
fn main() { let r = Real { name: f"" }; let a: i64 = r.in_function(f"f{1}", fn() { return 7 }); println(f"{a}") }

Writing the argument out, r.in_function[i64](...), is a parse error (“Expected } here, but found (”).

Probe 3, method of a trait through a bound: NK1103 (“This value is R, but the let declares i64”):

trait Host { fn in_function[R](self, name: String, at: i64, run: fn() -> R sync) -> R sync }
fn proven[H: Host](host: H) { let a: i64 = host.in_function(f"f", 1, fn() { return 7 }) }

Here R is not substituted through the bound.

To build

Found while writing the decision paper on a generic proofs::in_function (self-hosting, ADR-294).

Back to Open Issues