You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generic functions do not infer T from Vec[Task[T]] parameters #595
Codegen generic binding fails to infer a type parameter nested under Vec[Task[T]], even though the same shape is valid in concrete code. This surfaced while implementing #421: inlining cleanup loops works, but extracting them into a generic helper fails.
Minimal reproduction
//! expect-stdout: ok
fn cleanup_remaining[T](tasks: Vec[Task[T]], start: i32):
let total = tasks.len() as i32
var i = start
while i < total:
tasks.get(i).join_cleanup()
i = i + 1
async fn child() -> i32:
1
async fn main_task -> i32:
let tasks: Vec[Task[i32]] = Vec.new()
tasks.push(child())
cleanup_remaining(tasks, 0)
0
fn main:
let _ = main_task().await
print("ok")
Expected
T is inferred as i32, the helper is monomorphized, and the program prints ok.
Actual
error: unknown type for generic parameter 'T' in 'cleanup_remaining'
error: code generation failed
Notes
#421 avoids this by keeping the cleanup loops inline in std.task, but this is a real generic inference/codegen bug and should be fixed at the generic parameter binding layer, not worked around in user code.
Status update (skepticism pass, 2026-07-02): MUTATED AND WORSE on HEAD. The reported 'unknown type for generic parameter T' diagnostic is gone; with build on the repro now SIGSEGVs the compiler (exit 139, zero output, no diagnostic; check passes). A silent compiler crash is strictly worse than a clean rejection — escalating this to the front of the generics track.
Fixed by the commit above: codegen's generic monomorphization now unifies the param type node STRUCTURALLY against the argument's sema type (worklist over named leaves / ref-ptr unwrap / generic-inst recursion), binding T at any nesting depth — Vec[Task[T]] vs Vec[Task[i32]] → T=i32. The repro builds and runs (ok); the compiler SIGSEGV (and the original 'unknown type for generic parameter T') are gone. Pinned by behav_generic_nested_type_param covering Vec[Pair[T]], Pair[Vec[T]], and the async Vec[Task[T]] shape. Spec §11 generics; full gates green.
Activity
ehartford commentedon Jul 2, 2026
Status update (skepticism pass, 2026-07-02): MUTATED AND WORSE on HEAD. The reported 'unknown type for generic parameter T' diagnostic is gone;
with buildon the repro now SIGSEGVs the compiler (exit 139, zero output, no diagnostic;checkpasses). A silent compiler crash is strictly worse than a clean rejection — escalating this to the front of the generics track.ehartford commentedon Jul 2, 2026
Fixed by the commit above: codegen's generic monomorphization now unifies the param type node STRUCTURALLY against the argument's sema type (worklist over named leaves / ref-ptr unwrap / generic-inst recursion), binding T at any nesting depth —
Vec[Task[T]]vsVec[Task[i32]]→ T=i32. The repro builds and runs (ok); the compiler SIGSEGV (and the original 'unknown type for generic parameter T') are gone. Pinned by behav_generic_nested_type_param covering Vec[Pair[T]], Pair[Vec[T]], and the async Vec[Task[T]] shape. Spec §11 generics; full gates green.Fix #595: structural type-param unification in generic monomorphization