Skip to content

Can't use iterators named [] #14860

Closed
@dawkot

Description

@dawkot

Example

type
  Dummie = object

iterator `[]`(d: Dummie, a, b: int): int = discard

let d = Dummie()

for s in d[0, 1]: discard # error here

Current Output

type mismatch: got <T>

but expected one of:
iterator items(E: typedesc[enum]): E:type
first type mismatch at position: 1
required type for E: type enum
but expression 'd[0, 1]' is of type: T
iterator items(a: cstring): char
first type mismatch at position: 1
...

Additional Information

Tested with 1.2.4 and 1.3.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions