Skip to content

§11.7: expr[index] does not dispatch to IndexGet[I, V] and rejects non-integer I on IndexPlace[I, V] #3046

Closed

Description

@ehartford

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

  1. 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).
  2. 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

  1. added
    spec-gap
    on Nov 5, 2026
  2. added a commit that references this issue on Nov 6, 2026
  3. ehartford commented on Nov 6, 2026

    @ehartford
    ContributorAuthor

    Fixed in #3054 (merged as 12489f1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    spec-gap

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions