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 destructuring is broken with closure iterators #15924

Closed
a-mr opened this issue Nov 11, 2020 · 3 comments · Fixed by #23205
Closed

Tuple destructuring is broken with closure iterators #15924

a-mr opened this issue Nov 11, 2020 · 3 comments · Fixed by #23205
Assignees

Comments

@a-mr
Copy link
Contributor

a-mr commented Nov 11, 2020

Compiler crashes with --gc:orc or has an internal error:

Example

iterator walk(): (int, int) {.closure.} =
  yield (10,11)

for (i,j) in walk():
  echo i

Current Output

nim c --gc:orc myng7.nim
Hint: used config file '/home/amakarov/activity-public/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/amakarov/activity-public/Nim/config/config.nims' [Conf]
Hint: used config file '/home/amakarov/activity-personal/nim-try/nim.cfg' [Conf]
....SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Expected Output

not to crash

Possible Solution

Additional Information

$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2020-11-09
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: 53eca459f1d96c710238be95bd3fb048b336f2f3
active boot switches: -d:release

Possibly related with #15896.

@cooldome
Copy link
Member

I had a look it is not arc related. Closure iterators and tuple unpacking don't play together in any gc mode

@a-mr
Copy link
Contributor Author

a-mr commented Nov 12, 2020

It may be something very simple. When I rewrite it trivially without destructuring in the header of for, it works fine:

for x in walk():
  let (a, b) = x
  echo a, b, x

@ringabout
Copy link
Member

iterator walk(): (int, int) {.closure.} =
  yield (10,11)

for i,j in walk():
  echo i

This works.

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

Successfully merging a pull request may close this issue.

4 participants