`Error: cannot evaluate at compile time: v` with `template` in `const` context
### Description

```nim
type J = object

template m(u: J): int =
  let v = u
  0

proc g() =
  const x = J()
  const _ = m(x)

g()
```


### Nim Version

```
Nim Compiler Version 2.0.14 [Linux: amd64]
Compiled at 2025-01-21
Copyright (c) 2006-2023 by Andreas Rumpf

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

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

git hash: 12347eae74dbaa0e4dd99691e3a4509e8fe8b265
active boot switches: -d:release
```

```
Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2025-01-21
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: 793baf34ff72cb8c5485ce209af086e27f656853
active boot switches: -d:release
```

### Current Output

```text
k.nim(4, 7) Error: cannot evaluate at compile time: v`gensym0
```

### Expected Output

```text
Compiles
```

### Known Workarounds

_No response_

### Additional Information

_No response_