`Error: internal error: /tmp/Nim/compiler/semtypes.nim(2170, 7)`
### Description

```nim
proc b(G: type) =
  type U = G
template s(h: untyped) = h
s(b(typeof (0, 0)))
```

### Nim Version

```
Nim Compiler Version 2.0.8 [Linux: amd64]
Compiled at 2024-09-28
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-28
Copyright (c) 2006-2023 by Andreas Rumpf

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

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

git hash: 4f5c0efaf24e863b26b16d7998eac3bdd830e7be
active boot switches: -d:release
```

### Current Output

```text
Error: internal error: /tmp/Nim/compiler/semtypes.nim(2170, 7)
No stack traceback available
To create a stacktrace, rerun compilation with './koch temp c <file>', see https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler for details
```


### Expected Output

```text
no Nim compiler internal error
```


### Known Workarounds

_No response_

### Additional Information

_No response_