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
IndexPlace on a generic user type is not dispatched (bounded impl unseen, unbounded impl fails inference); IndexGet cannot yield a view #2560
IndexPlace on a generic user type does not dispatch (spec §2.4, §11 "user types implementing IndexGet/IndexPlace").
pub type Box3[T] { items: List[T] }
impl[T: Copy] IndexPlace[isize, T] for Box3[T]:
fn get(self: &Self, index: isize) -> T: self.items[index]
mut fn set(index: isize, value: T): self.items[index] = value
fn main:
var b = Box3 { items: [1, 2, 3] }
b[1] = 9
print(b[1])
gives type 'Box3[isize]' cannot be indexed: it is not a positional collection and implements no IndexPlace (the index type is also inferred as the type argument). Without the bound (impl[T] IndexPlace[isize, T] for Box3[T]) the read fails with cannot infer type parameter 'T' for this call; the argument's shape does not match the parameter type that mentions 'T'. A non-generic impl IndexPlace[i32, i32] for Grid works (behav_index_place_user.w).
lib/std/traits.w notes that a formal impl IndexPlace for List[T] waits on generic trait method bodies; the same gap blocks Deque[T] (std.collections.deque, Phase 3 of the stdlib sourcing plan), which offers get(i) -> &T until d[i] works. IndexGet returning a &T view (D27's element view for a user type) is the second half of the same item.
Expected: b[1] = 9; b[1] reads 9 through the impl; Deque[T] spells element access d[i].
Fixed in #2614 (main 23dd9db). Sema records the specialized get/set per subscript (record_index_place_contracts) and settles a bounded blanket impl against the instance (index_place_insts, IndexPlace or IndexGet); MirLower lowers the recorded contract, borrowing the receiver place for get(self: &Self), and a subscript as a place materializes a temp. IndexGet yielding a view works too: Deque and Stack now implement IndexGet[isize, &T] and spell d[i]. Fixture test/behavior/behav_index_place_generic.w (bounded and unbounded impls, two instantiations, compound store, call-argument subscript, IndexGet views); an IndexGet-only store is refused.
Activity
Phase 3 facades over the STC engines (D148): PriorityQueue, OrderedSe…
docs: stdlib_sourcing_plan reflects the implemented state (all four p…
Stdlib sourcing close-out: Stack/Queue/LinkedList, stable_sort/shuffl…
ehartford commentedon Oct 24, 2026
Fixed in #2614 (main 23dd9db). Sema records the specialized get/set per subscript (record_index_place_contracts) and settles a bounded blanket impl against the instance (index_place_insts, IndexPlace or IndexGet); MirLower lowers the recorded contract, borrowing the receiver place for get(self: &Self), and a subscript as a place materializes a temp. IndexGet yielding a view works too: Deque and Stack now implement IndexGet[isize, &T] and spell d[i]. Fixture test/behavior/behav_index_place_generic.w (bounded and unbounded impls, two instantiations, compound store, call-argument subscript, IndexGet views); an IndexGet-only store is refused.
D172: `mut` parameters, access at call activation, D144 for elements
D172: `mut` parameters, access at call activation, D144 for elements (#…