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

Tuple unpacking of `for` vars fails inside generic proc #10727

Clyybber opened this issue Feb 23, 2019 · 2 comments


None yet
3 participants
Copy link

commented Feb 23, 2019

The following snippet doesn't compile.
When the generic parameter is removed it does compile.


func test[n](s: seq[(int, int)]) =
  for (a, b) in s:

Current Output

test.nim(2, 7) Error: illformed AST: (a) =

Expected Output

It should just compile.

Additional Information

Tuple unpacking for for variables introduced in #10152 by @nc-x

$ nim -v
Nim Compiler Version 0.19.9

This comment has been minimized.

Copy link

commented Feb 24, 2019

Looking at this it looks like the for loop construct inside a proc parameterized by a type takes a completely path vs. one without a generic. The former ends up here while the latter ends up here. Is there a reason there's two different ways of doing almost the same thing?

deech added a commit to deech/Nim that referenced this issue Feb 24, 2019

@Araq Araq closed this in 68a82f1 Feb 25, 2019


This comment has been minimized.

Copy link

commented Feb 25, 2019

The reason is that generics have two-phase symbol lookup rules and non-generics don't. Covered by the manual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.