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
§11.7: expr[index] does not dispatch to IndexGet[I, V] and rejects non-integer I on IndexPlace[I, V] #3046
Found during the #2987 manual audit of docs/spec/011_traits.md (§11.7, lines 314–354).
Minimal reproduction
type Matrix { data: List[f64], rows: usize, cols: usize }
impl IndexGet[(usize, usize), f64] for Matrix:
fn get(self: &Self, rc: (usize, usize)) -> f64:
let (r, c) = rc
self.data[(r * self.cols + c) as isize]
fn main:
let m = Matrix { data: [1.0, 2.0, 3.0, 4.0], rows: 2, cols: 2 }
print(m[(1usize, 0usize)])
Actual
IndexGet-only types fail with error: type 'Matrix' cannot be indexed: it is not a positional collection and implements no IndexPlace (lib/std/traits.w:394 defines IndexGet[I, V], and §11.7 lists IndexGet[I, O] as the read-only expr[index] syntax trait).
Even on IndexPlace[(usize, usize), f64], m[(1usize, 0usize)] fails with error: index expression must be an integer; this one is (usize, usize) instead of checking the index operand against the impl's I parameter type.
Activity
#3044, #3046, #3047 (Gap 1), #3048, #3049: five spec-gap fixes from the
ehartford commentedon Nov 6, 2026
Fixed in #3054 (merged as 12489f1).