Segmentation fault upon compilation with recursive typeclass definitions
### Description

Simple version:
```nim
type
  A = A | B
  B = A | B
discard 0 is A
```

But it scales to where it's nontrivial to spot the cycles on observation, even with all the typeclasses right there:
```nim
type
  A = K | C
  B = J | A
  C = H | R
  D = T | S
  E = W | O
  F = M | S
  G = X | B
  H = P | Q
  I = W | G
  J = I | E
  K = U | O
  L = X | D
  M = B | N
  N = R | L
  O = L | Q
  P = V | F
  Q = A | N
  R = H | E
  S = J | M
  T = I | P
  U = F | T
  V = D | C
  W = K | G
  X = V | U
discard 0 is M
```

Adding concrete terminal types doesn't work around it:
```nim
type
  S = A | C
  N = W | F
  L = object
  C = object
  E = V | K
  X = Y | M
  W = object
  P = object
  V = B | H
  F = object
  B = U | E
  D = S | J
  M = object
  A = object
  H = object
  U = X | D
  Y = L | T
  J = object
  T = object
  K = N | P
discard 0 is E
```

### Nim Version

```
Nim Compiler Version 2.0.10 [Linux: amd64]
Compiled at 2024-08-01
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 92e505577e8b6b9214b6fcdd7fe1b0e9a244023b
active boot switches: -d:release
```

```
Nim Compiler Version 2.1.9 [Linux: amd64]
Compiled at 2024-08-01
Copyright (c) 2006-2024 by Andreas Rumpf

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

### Current Output

```text
.....................................................................Segmentation fault
```


### Expected Output

```text
No Segmentation fault
```


### Possible Solution

_No response_

### Additional Information

_No response_