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
Move checker double-visits chained method-call receivers: spurious "use of moved value" and doubled diagnostics #573
Spec reference: §3.8 (by-value consume). Found while conforming the test corpus for #564 on the flipped-gate staged compiler.
A non-Copy local consumed exactly once is rejected when the consuming call is the receiver of a chained method call:
type S { a: str, b: str }
fn mk(a: str) -> S:
S { a, b: "" }
fn use1(s: S) -> Result[i64, str]:
let _ = s.a
if s.b.contains("x"):
return Ok(7)
Err("no")
fn main:
let src = mk("xyz")
let v = use1(src).unwrap() // error: use of moved value (src)
print(int_to_string(v))
Splitting the chain makes it pass, with identical semantics:
let r = use1(src)
let v = r.unwrap() // ok
WITH_DEBUG_MOVE=1 shows the receiver subtree is move-checked twice — src is marked moved on the first walk, then flagged as a moved use on the second:
The double walk also duplicates genuine diagnostics: every "use of moved value" inside a chained receiver is reported exactly twice (e.g. the errors for test/behavior/behav_cli_test_command_args.w before its fix). The consumed local can be nested arbitrarily deep in the receiver's argument tree (dispatch(stream, prog, bindings_from(entries)).unwrap() falsely flags entries).
Pre-flip installed compiler accepts the repro. Diagnostic site: src/SemaCheck.w:4348 (check_ident MOVED state) / mark_moved_if_consumed.
Workaround in tree (remove when fixed): test/behavior/issue59_demo_{binding_order_independent,pair_asserts,pair_asserts_dump_mir,pair_print}.w hoist let bindings = bindings_from(entries) out of the chained dispatch(...).unwrap() call.
Root-caused. check_call on a chained call (use1(src).unwrap()) runs the receiver subtree through full, effectfulcheck_expr twice:
The callable-field probe (SemaCheck.w:9012): "is .unwrap a callable struct field?" calls field_access_type_no_diagnostic(callee), which at :6498 does an unconditional check_expr(expr) on the base use1(src) — the inner call's §3.8 gate marks src MOVED. The probe is "no_diagnostic" in name only.
The real check: the probe returns non-callable → check_method_call_parts re-checks the same receiver at :11626; the arg re-check sees MOVED → spurious "use of moved value", and the gate marks again.
Same family: check_pipeline (|> — confirmed false positive, :8323 + :8339-8365) and check_membership_operator (in, :4880). Collateral from the double visit: every diagnostic in a chained receiver emits twice; note_allocation_site records duplicate alloc sites (doubled no_alloc errors, skewed accounting); duplicate SHARED borrows registered (latent §15 landmine). Idempotent: effect bits, typed_expr_types.
Recommended fix (validated design, low risk): compute the receiver type once — split field_access_type_no_diagnostic so check_call checks the base itself and probes with a pure field_access_type_from_obj(base_ty, field); add a recv_ty hint param to check_method_call_parts (0 = compute) and pass the known type from check_call/check_pipeline/check_membership. Rejected: cache-first typed_expr_types (stale across generic re-instantiation — check_fn_body_concrete re-checks the same nodes per specialization); a suppress flag (under-checks the genuine callable-field path); deduping only the move-mark (leaves the doubled diagnostics/borrows).
Closing as fixed on current HEAD: the chained method-call receiver repro compiles with no spurious 'use of moved value' and no doubled diagnostics (the only remaining output is a legitimate runtime unwrap panic from the repro's own Err). The move-checker receiver handling was reworked during the #605/#606/#607 campaign (field-read drop suppression fix + Slice E receiver consume).
Activity
ehartford commentedon Jun 13, 2026
Root-caused.
check_callon a chained call (use1(src).unwrap()) runs the receiver subtree through full, effectfulcheck_exprtwice:.unwrapa callable struct field?" callsfield_access_type_no_diagnostic(callee), which at :6498 does an unconditionalcheck_expr(expr)on the baseuse1(src)— the inner call's §3.8 gate markssrcMOVED. The probe is "no_diagnostic" in name only.check_method_call_partsre-checks the same receiver at :11626; the arg re-check sees MOVED → spurious "use of moved value", and the gate marks again.Same family:
check_pipeline(|>— confirmed false positive, :8323 + :8339-8365) andcheck_membership_operator(in, :4880). Collateral from the double visit: every diagnostic in a chained receiver emits twice;note_allocation_siterecords duplicate alloc sites (doubled no_alloc errors, skewed accounting); duplicate SHARED borrows registered (latent §15 landmine). Idempotent: effect bits, typed_expr_types.Recommended fix (validated design, low risk): compute the receiver type once — split
field_access_type_no_diagnosticso check_call checks the base itself and probes with a purefield_access_type_from_obj(base_ty, field); add arecv_tyhint param tocheck_method_call_parts(0 = compute) and pass the known type from check_call/check_pipeline/check_membership. Rejected: cache-first typed_expr_types (stale across generic re-instantiation — check_fn_body_concrete re-checks the same nodes per specialization); a suppress flag (under-checks the genuine callable-field path); deduping only the move-mark (leaves the doubled diagnostics/borrows).ehartford commentedon Jul 2, 2026
Closing as fixed on current HEAD: the chained method-call receiver repro compiles with no spurious 'use of moved value' and no doubled diagnostics (the only remaining output is a legitimate runtime unwrap panic from the repro's own Err). The move-checker receiver handling was reworked during the #605/#606/#607 campaign (field-read drop suppression fix + Slice E receiver consume).