S0010: indexing requires an array
Generated from rellum-diagnostics/src/db.rs.
Explanation
Index expressions read an element from an array value. Scalars, tuples, records, enums, and non-array Shared[T] handles do not have array element storage, so they cannot be indexed.
Common causes
- indexing a scalar value such as Int, Bool, Char, or String
- using [] on a tuple instead of .N field access
- indexing a Shared[T] handle whose inner type is not an array
Canonical fixes
- index an array value
Before:
first = item[0]
After:
items = [item]
first = items[0]
- use tuple field access for tuple values
Before:
first = pair[0]
After:
first = pair.0
Code example
first = item[0]