Compiling with Nim v2.2.0 gives SIGSEGV for yaml loading code
### Description

Using Nim v2.2.0, when I compile code that loads yaml (standard library) into an object that contains a ref object, the compiler crashes with a sigsegv.

### Nim Version

2.2.0

### Current Output

```text
nexus/src/nexus/cmd$ nim --path:../.. -d:ssl c programs/nexus.nim
Hint: used config file '/home/user/.choosenim/toolchains/nim-2.2.0/config/nim.cfg' [Conf]
Hint: used config file '/home/user/.choosenim/toolchains/nim-2.2.0/config/config.nims' [Conf]
......................................................................................................................................................................................................................................................................
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
```


### Expected Output

```text
Best case is that the code compiles without any problem. But in the worst case it should give a valid error message and not crash.
```


### Known Workarounds

For the object trying to be loaded, convert any ref objects to objects.

### Additional Information

Test case:

```nim
import streams, yaml


type
  Item* = ref object of RootObj
    name*: string


# Load YAML
var
  item: Item
  s = newFileStream("test.yaml")

load(s, item)
s.close()
```