Regression from 2.0.8/`version-2-0` to `version-2-2`/`devel` with `Error: type mismatch` with templates and generics
### Description

```nim
template v[T, S](c: S): T = T(c)
discard v[int](0)
```

### Nim Version

Builds:
```
Nim Compiler Version 2.0.8 [Linux: amd64]
Compiled at 2024-09-16
Copyright (c) 2006-2023 by Andreas Rumpf

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

```
Nim Compiler Version 2.0.9 [Linux: amd64]
Compiled at 2024-09-16
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 3214174f06930d240b0e35cb35c22014b89d1272
active boot switches: -d:release
```

Doesn't build:
```
Nim Compiler Version 2.1.99 [Linux: amd64]
Compiled at 2024-09-17
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 61e04ba0ed4b8c6567f4cfd5c48c2c2439c62371
active boot switches: -d:release
```

```
Nim Compiler Version 2.1.99 [Linux: amd64]
Compiled at 2024-09-17
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 1fbb67ffe9d3ec71fb1424609831eaca648c96d3
active boot switches: -d:release
```

### Current Output

```text
/tmp/k.nim(2, 15) Error: type mismatch
Expression: v[int](0)
  [1] 0: int literal(0)
```


### Expected Output

_No response_

### Known Workarounds

_No response_

### Additional Information

_No response_