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
Auto-ref does not fire for a generic parameter bound &C — count_all(v) rejected where count_all(&v) works #737
use std.collections
fn count_all[C: IntoIter[i32]](c: &C) -> i32:
var walker = c.iter()
...
fn main:
var v: Vec[i32] = Vec.new()
v.push(1)
print(int_to_string(count_all(v) as i64)) // rejected
let vr = &v
print(int_to_string(count_all(vr) as i64)) // works
Two things wrong. The auto-referencing rule (CLAUDE.md: "peek(x) is the
ordinary spelling when peek takes &T") does not fire when the parameter is &C for a generic C — the caller is forced to spell &v, which is exactly
the ceremony the mission forbids. And the diagnostic reports the expectation as &i32 (the trait's element type) rather than &C/&Vec[i32], so it points at
the wrong type entirely.
Found while verifying #716's iter()-on-borrowed-receiver conformance (that part
now works; this is the generic-parameter auto-ref gap next to it).
Fixed in 9c3b761 (battery green: build, fixpoint, :test, :move-audit, :drop-audit; seed + installed compiler now v0.15.1-g9c3b76193).
Two exact-line root causes, both proven before fixing (lldb backtrace + --dump-abi):
bind_type_params_from_type_expr's NK_TYPE_REF arm only bound the pointee when the argument was itself a reference — the auto-ref spelling count_all(v) left C unbound, and the silent unbound-param default then made C = i32, which is where the phantom 'expects &i32' came from. The arm now binds the pointee from the place type, per §3.8. The silent i32 default itself is a separate no-silent-fallback violation, filed as Uninferable-but-mentioned generic type param silently defaults to i32, producing phantom 'expects &i32' diagnostics #738.
check_call's unknown-signature path conservatively marked every non-Copy argument moved, and a generic callee always reaches it (no sig until specialization) — so even after inference the plain spelling consumed v (let vr = &v after the call reported use-of-moved). Arguments bound to a declared &T param now skip the conservative marking; the signature is authoritative.
Behavior fixture issue737_generic_ref_param_autoref.w pins both spellings, post-call liveness of the argument, and unbounded [T] auto-ref. Bonus from the same battery cycle: the reseeded gate-bearing seed caught two real Drop-element copies in build/emit_c.w that no earlier battery could see (build scripts compile under the seed) — fixed in 757bfc1.
Activity
ehartford commentedon Jul 28, 2026
Fixed in 9c3b761 (battery green: build, fixpoint, :test, :move-audit, :drop-audit; seed + installed compiler now v0.15.1-g9c3b76193).
Two exact-line root causes, both proven before fixing (lldb backtrace + --dump-abi):
bind_type_params_from_type_expr's NK_TYPE_REF arm only bound the pointee when the argument was itself a reference — the auto-ref spellingcount_all(v)left C unbound, and the silent unbound-param default then made C = i32, which is where the phantom 'expects &i32' came from. The arm now binds the pointee from the place type, per §3.8. The silent i32 default itself is a separate no-silent-fallback violation, filed as Uninferable-but-mentioned generic type param silently defaults to i32, producing phantom 'expects &i32' diagnostics #738.check_call's unknown-signature path conservatively marked every non-Copy argument moved, and a generic callee always reaches it (no sig until specialization) — so even after inference the plain spelling consumedv(let vr = &vafter the call reported use-of-moved). Arguments bound to a declared&Tparam now skip the conservative marking; the signature is authoritative.Behavior fixture issue737_generic_ref_param_autoref.w pins both spellings, post-call liveness of the argument, and unbounded
[T]auto-ref. Bonus from the same battery cycle: the reseeded gate-bearing seed caught two real Drop-element copies in build/emit_c.w that no earlier battery could see (build scripts compile under the seed) — fixed in 757bfc1.#737: a generic &C parameter borrows — infer through auto-ref, do not…
Handoff: D27 enshrined and E1+E2 landed; stage2 miscompile blocks the…
Sema: a pipeline stage consumes its by-value arguments like the direc…
Type checker: D74 entry sources and chain moves, field-view bindings (#…