Nim
Nim copied to clipboard
Invalid C code generation with templates
Nim Version
Nim Compiler Version 2.2.4 [Linux: amd64]
Compiled at 2025-06-08
Copyright (c) 2006-2025 by Andreas Rumpf
git hash: f7145dd26efeeeb6eeae6fff649db244d81b212d
active boot switches: -d:release
Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2025-06-10
Copyright (c) 2006-2025 by Andreas Rumpf
git hash: 638a8bf84d35c6be54cd7e4b4642ce77ae83da39
active boot switches: -d:release
Description
proc w(_: int): bool = discard
proc b() =
template m(c: int) =
if w(c): discard w(c)
m((; let _ = 0; if true: 0 else: 0))
b()
Current Output
/tmp/tmp.iokGrWTR6P/@ms.nim.c: In function ‘b__s_u4’:
/tmp/tmp.iokGrWTR6P/@ms.nim.c:77:20: error: redeclaration of ‘__1’ with no linkage
77 | NI __1;
| ^~~
/tmp/tmp.iokGrWTR6P/@ms.nim.c:75:20: note: previous declaration of ‘__1’ with type ‘NI’ {aka ‘long int’}
75 | NI __1;
| ^~~
Expected Output
No invalid C code generation
Known Workarounds
No response
Additional Information
No response
!nim c --gc:refc
proc w(_: int): bool = discard
proc b() =
template m(c: int) =
if w(c): discard w(c)
m((; let _ = 0; if true: 0 else: 0))
b()
:penguin: Linux bisect by @ringabout (member)
devel :-1: FAIL
Output
Filesize 0 (0 bytes)
Duration
stable :-1: FAIL
Output
Filesize 0 (0 bytes)
Duration
2.2.2 :-1: FAIL
Output
Filesize 0 (0 bytes)
Duration
2.0.0 :-1: FAIL
Output
Filesize 0 (0 bytes)
Duration
1.6.20 :-1: FAIL
Output
Filesize 0 (0 bytes)
Duration
1.4.8 :-1: FAIL
Output
Filesize 0 (0 bytes)
Duration
1.2.18 :-1: FAIL
Output
Filesize 0 (0 bytes)
Duration
1.0.10 :-1: FAIL
Output
Filesize 0 (0 bytes)
Duration
Stats
- GCC
13.3.0 - Clang
18.1.3 - NodeJS
19.2 - Created
2025-06-10T14:51:55Z - Comments
1 - Commands
nim c --gc:refc --run -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
:robot: Bug found in 21 mins bisecting 8 commits at 0 commits per second
Duplicates of https://github.com/nim-lang/Nim/issues/15637