Regression: Error: fatal error: invalid kind for lastOrd(tyGenericParam)
### Description

Git bisect shows this is a regression, caused by https://github.com/nim-lang/Nim/pull/23137.

One part of these errors was fixed in https://github.com/nim-lang/Nim/pull/23760, but not all cases are fixed. For example:

```nim
func `xor`[T: array](a, b: T): T =
  for i in 0..<result.len:
    result[i] = a[i] xor b[i]

template eachElement(x, y, res, op: untyped) =
  for i in 0..<res.len:
    res[i] = op(x[i], y[i])

func `xor`*[N: static int; T](x, y: array[N, T]): array[N, T] =
  eachElement(x, y, result, `xor`)

var a: array[5, int]
var b: array[5, int]

discard a xor b
```

### Nim Version

```
$ nim -v
Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2024-07-11
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 5c5e7a9b6e9ed0c860030f798d4a7096b51b6bda
active boot switches: -d:release
```

### Current Output

```text
`Error: fatal error: invalid kind for lastOrd(tyGenericParam)`
```


### Expected Output

_No response_

### Possible Solution

_No response_

### Additional Information

_No response_