Identifiers in templates not gensym'ed when declared in nested template invocation
### Description

This produces a "redefinition of `a`" error:
```nim
template declare1(x: untyped) =
    let x = 1

template declare2(x: untyped) =
    declare1 a
    let x = a + 1

declare2 a
assert a == 2
```
An explicit `{.gensym.}` pragma does not help (still causes a redefinition error):
```nim
template declare1(x: untyped) =
    let x = 1

template declare2(x: untyped) =
    declare1(a {.gensym.})
    let x = a + 1

declare2 a
assert a == 2
```

### Investigation

Implementing `declare1` as a macro and inspecting `x` shows that it is given as a simple ident instead of a gensym symbol, even with the explicit `{.gensym.}` pragma from before:
```nim
import macros

macro declare1(x: untyped) =
    echo x.lispRepr # outputs (PragmaExpr (Ident "a") (Pragma (Ident "gensym")))
    result = quote do:
        let `x` = 1

template declare2(x: untyped) =
    declare1(a {.gensym.})
    let x = a + 1

declare2 a
assert a == 2
```

### Discussion

First of all, note that this issue is similar to #24260, but the focus there was on how templates ignore gensyms in their names, while this issue is focused on identifiers not being gensym'ed.

I originally expected that _every_ identifier that is "created" in a template, in the sense that it does not refer to an existing symbol, should be gensym'ed. In this way, everything that would later be derived from that identifier (like a `let` declaration in `declare1`) would only be visible in the template that created the identifier (`declare2`), not the surrounding scope. This is currently only the case for identifiers that are directly used in declarations like `let a = 1`.

However, as @metagn [noted](https://github.com/nim-lang/Nim/issues/24260#issuecomment-2399446570), an automatic gensymming of identifiers cannot be done in templates, because identifiers could be bound at the instantiation site.

Even if not _every_ identifier should be gensym'ed, I still think identifiers that are "later" used in declarations should/could be retroactively gensym'ed. Although I'm not sure whether this can be implemented (easily).

Another alternative that [was mentioned by @metagn](https://github.com/nim-lang/Nim/issues/24260#issuecomment-2399446570) is what I tried to do myself: using the `{.gensym.}` pragma to force identifiers to be gensym'ed, even if they aren't immediately used in a declaration.

### Nim Version

Nim Compiler Version 2.0.8 [Linux: amd64]
Compiled at 2024-07-03
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 5935c3bfa9fec6505394867b23510eb5cbab3dbf
active boot switches: -d:release

### Current Output

```text
/tmp/declare.nim(8, 10) Error: redefinition of 'a'; previous declaration here: /tmp/declare.nim(5, 14)
```


### Expected Output

```text
(empty)
```


### Known Workarounds

- use a different name for the temporary variable. note that this still (unintentionally) leaks the temporary:
  ```nim
  template declare1(x: untyped) =
      let x = 1
  
  template declare2(x: untyped) =
      declare1 b
      let x = b + 1
  
  declare2 a
  assert a == 2
  assert b == 1 # works! (not good)
  ```

- do not use nested template invocations:
  ```nim
  template declare(x: untyped) =
      let a = 1
      let x = a + 1
  
  declare a
  assert a == 2
  ```

### Additional Information

Also checked with versions (same error everywhere):
- 1.0.0
- 1.2.0
- 1.4.0
- 1.6.0
- 2.0.0
- devel (b9de2bb4f3864d264c3aeffdc630227448ad8c14)