-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Invalid C code for inline iterator with inner proc #14165
Comments
@timotheecour your #18536 seems to be a duplicate of this issue, can you please decide which one of the two to close? |
ok, closing the other one in favor of this one; there is some complementary information so I'm pasting the issue here: 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
Expected Outputworks Additional Information1.5.1 73ce40a |
I'm not sure, but I think I ran into this same bug using an anonymous proc passed to another proc. The error message is exactly the same except for the names. I will post an example here if I manage to get it minimized, but its hard because my bug happened with regex-nim and removing regex-nim usage in my program makes it compile. By the way the original example posted here now doesn't compile with arc on Nim 1.4.8. |
Hi @Cloudperry, could you post your example? |
Unfortunately it happened in one of my super small projects and I didn't have the code in any version control system. I got rid of that code because I thought that an example with regex-nim wouldn't be that useful. I tried to make the same program again from what I remember but I didn't manage to reproduce it. |
While trying out the different nim solutions to the Hamming numbers task from RosettaCode I found that one variant did not compile. Reducing it to the max gave me this:
Output
This is the expansion of the second loop.
Additional Information
--gc:arc
the compilation succeeds.Used versions
The text was updated successfully, but these errors were encountered: