jsondoc `IndexDefect` with `auto` return type
### Nim Version

Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2025-02-28
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: 7e8a650729e9434574c46350aece7609e5465253
active boot switches: -d:release


### Description

Running `jsondoc` (but not `doc`) fails with this example
```nim
# Only works with unrestrained types like `ref` and `proc`. Normal generic doesn't fail
proc test*(x: ref): auto = ""
```

### Current Output

```text
nim/compiler/nim.nim(169) nim
nim/compiler/nim.nim(124) handleCmdLine
nim/compiler/main.nim(353) mainCommand
nim/compiler/main.nim(118) commandDoc2
nim/compiler/pipelines.nim(311) compilePipelineProject
nim/compiler/pipelines.nim(231) compilePipelineModule
nim/compiler/pipelines.nim(178) processPipelineModule
nim/compiler/pipelines.nim(42) processPipeline
nim/compiler/docgen2.nim(61) processNodeJson
nim/compiler/docgen.nim(1580) generateJson
nim/compiler/docgen.nim(1210) genJsonItem
nim/compiler/types.nim(792) typeToString
nim/compiler/types.nim(714) typeToString
nim/compiler/ast.nim(1329) elementType
nim/lib/system/indices.nim(30) []
nim/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexDefect]
```

### Expected Output

```text
Doesn't crash
```

### Known Workarounds

_No response_

### Additional Information

_No response_