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
A method call on a collection literal under an outer demand types the literal by the demand: [1, 2, 3].traverse(...) with a Result[List[T], E] annotation reports "unknown method 'traverse' for type 'Result[isize]'" #3051
Spec: §4.3 / D93 (a collection literal is typed by its use) and §10.7 (List.traverse).
type Tracked { n: i32 }
fn main:
let r: Result[List[Tracked], str] = [1, 2, 3].traverse(n => Ok(Tracked { n }))
Actual (v0.16.0.8):
error: unknown method 'traverse' for type 'Result[isize]'
Expected: the literal is the receiver of traverse; the outer Result[List[Tracked], str] demand is the call's result type, not the receiver's. The literal is a List[isize] (or List[i32] once the closure's parameter use types it) and the call checks as it does when the literal is bound first:
let nums = [1, 2, 3]
let r: Result[List[Tracked], str] = nums.traverse(n => Ok(Tracked { n })) // works
Workaround used in test/debug_alloc/da_traverse_closure_per_element_and_fail_path.w: bind the literal first. Found while fixing the traverse closure-move / short-circuit leak (spec-gaps-3 batch).
Activity
Review fixes: traverse ownership, comptime Some from Sema's fact, one…
#3016, #3032, #2946, #2976, #2949, #3051, #3005, #3001, #3017, #2521:…
ehartford commentedon Nov 7, 2026
Fixed in #3056 (merged as afbdbb1).