Compiler crash on template evaluation for generic `static int`
### Description

```nim
type ArrayBuf*[N: static int, T = byte] = object
  buf: array[N, T]

template maxLen(T: type): int =
  sizeof(T) * 2

type MyBuf[I] = ArrayBuf[maxLen(I)]

var v: MyBuf[int]
```

same as #24043, but with a template

### Nim Version

2.0.8

### Current Output

```
nim c -r "testit.nim"
.......................................................................................................................SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault (core dumped)
```

### Expected Output

_No response_

### Known Workarounds

_No response_

### Additional Information

_No response_