Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use iterators named [] #14860

Open
dawkot opened this issue Jun 30, 2020 · 2 comments
Open

Can't use iterators named [] #14860

dawkot opened this issue Jun 30, 2020 · 2 comments

Comments

@dawkot
Copy link

dawkot commented Jun 30, 2020

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

@jibal
Copy link

jibal commented Jul 4, 2020

Just noting that for s in `[]`(d, 0, 1): discard works.

@metagn
Copy link
Collaborator

metagn commented Oct 18, 2024

Works since 1.6

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

No branches or pull requests

3 participants