Skip to content

Invalid C code generation with iterator with when nimvm: error: ‘c__r_u3’ undeclared (first use in this function); did you mean ‘c__r_u10’ #25122

@tersec

Description

@tersec

Nim Version

Nim Compiler Version 2.2.4 [Linux: amd64]
Compiled at 2025-08-25
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: f7145dd26efeeeb6eeae6fff649db244d81b212d
active boot switches: -d:release
Nim Compiler Version 2.2.5 [Linux: amd64]
Compiled at 2025-08-25
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: c339651ae1d6af6c84f5489f6fe1fdea44ba1fa1
active boot switches: -d:release
Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2025-08-25
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: b527db9ddd33fd16a8afd8467344fec81a54c84d
active boot switches: -d:release
gcc (Debian 14.3.0-5) 14.3.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Description

iterator v(): int =
  when nimvm:
    yield 0
  else:
    yield 0
for _ in v():
  for c in v():
    (; let _: proc() = proc() = discard c)

Current Output

.....................................................................
CC: system/exceptions.nim
CC: std/private/digitsutils.nim
CC: system/dollars.nim
CC: system.nim
CC: r.nim
/tmp/tmp.YWdRaJqN4e/@mr.nim.c: In function ‘colonanonymous___r_u5’:
/tmp/tmp.YWdRaJqN4e/@mr.nim.c:82:7: error: ‘c__r_u3’ undeclared (first use in this function); did you mean ‘c__r_u10’?
   82 | (void)c__r_u3;
      |       ^~~~~~~
      |       c__r_u10
/tmp/tmp.YWdRaJqN4e/@mr.nim.c:82:7: note: each undeclared identifier is reported only once for each function it appears in

Expected Output

No invalid C code generated

Known Workarounds

No response

Additional Information

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions