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

inline iterator called twice gives cgen error #18536

Closed
timotheecour opened this issue Jul 20, 2021 · 1 comment
Closed

inline iterator called twice gives cgen error #18536

timotheecour opened this issue Jul 20, 2021 · 1 comment

Comments

@timotheecour
Copy link
Member

reduced from #18535 (comment) /cc @brightly-salty

Example

# iterator envPairs*(): int {.closure.} = # Error: internal error: environment misses: foo
iterator envPairs*(): int =
  var foo: seq[int]
  proc fun() =
    foo = @[]
  fun()
  yield 3

proc main() =
  for a in envPairs():
    discard
  for a in envPairs():
    discard
static: main() # nim c in vm: ok
# static: main() # nim js in vm: Error: cannot evaluate at compile time: foo
main() # nim c: @mt12609.nim.c:372:5: error: use of undeclared identifier 'colonenv_'; did you mean 'colonenv__2'?
# main() # nim js: # Error: internal error: symbol has no generated name: foo

Current Output

/@mt12609.nim.c:372:5: error: use of undeclared identifier 'colonenv_'; did you mean 'colonenv__2'?
                (*colonenv_).foo1 = (tySequence__qwqHTkRvwhrRyENtudHQ7g*)0;
                  ^~~~~~~~~
                  colonenv__2
/Users/timothee/git_clone/nim/timn/build/nimcache/@mt12609.nim.c:364:65: note: 'colonenv__2' declared here
                tyObject_Env_t12609dotnim_envPairs___Dwg4Sd9awieN34NfR6DSgaw* colonenv__2;
                                                                              ^
/Users/timothee/git_clone/nim/timn/build/nimcache/@mt12609.nim.c:375:46: error: use of undeclared identifier 'colonenv_'; did you mean 'colonenv__2'?
                T4_.ClP_0 = fun_t4950544857_3; T4_.ClE_0 = colonenv_;

Expected Output

works

Additional Information

1.5.1 73ce40a

@timotheecour
Copy link
Member Author

closing as duplicate of #14165

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

1 participant