`error: redeclaration of ‘qX60gensym0_’ with no linkage` with nested templates
### Description

```nim
template c(w: int): int =
  let q = w
  0

template t(r: (int, int); x: int) =
  for _ in r.fields:
    let w = x

proc k() =
  t((0, 0), c(0))

k()
```

Applies across Cartesian product of
- {`v2.0.10`, `version-2-0`, `version-2-2`, `devel`} x 
- {`nim c`, `nim cpp`} x
- {`--mm:refc`, `--mm:orc`}


### Nim Version

```
Nim Compiler Version 2.0.10 [Linux: amd64]
Compiled at 2024-10-21
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: e941ee15be775fe3c46db1bed9b4f41c7dfb1334
active boot switches: -d:release
```

```
Nim Compiler Version 2.0.11 [Linux: amd64]
Compiled at 2024-10-21
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: e334aad20220ddb5fad63002102d5557464f48c1
active boot switches: -d:release
```

```
Nim Compiler Version 2.2.0 [Linux: amd64]
Compiled at 2024-10-21
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 78983f1876726a49c69d65629ab433ea1310ece1
active boot switches: -d:release
```

```
Nim Compiler Version 2.2.1 [Linux: amd64]
Compiled at 2024-10-21
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 67442471ae4504bc074c8bb02308613fadc199f8
active boot switches: -d:release
```

### Current Output

```text
/tmp/tmp.Yj3mj2C0HM/@mn.nim.c: In function ‘k__n_u8’:
/tmp/tmp.Yj3mj2C0HM/@mn.nim.c:67:12: error: redeclaration of ‘qX60gensym0_’ with no linkage
   67 |         NI qX60gensym0_;
      |            ^~~~~~~~~~~~
/tmp/tmp.Yj3mj2C0HM/@mn.nim.c:65:12: note: previous declaration of ‘qX60gensym0_’ with type ‘NI’ {aka ‘long int’}
   65 |         NI qX60gensym0_;
      |            ^~~~~~~~~~~~
Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3 -pthread   -I/tmp/nim/lib -I/tmp -o /tmp/tmp.Yj3mj2C0HM/@mn.nim.c.o /tmp/tmp.Yj3mj2C0HM/@mn.nim.c' failed with exit code: 1
```


### Expected Output

```text
No invalid C codegen
```


### Known Workarounds

_No response_

### Additional Information

_No response_