mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-31 20:49:06 +00:00
Fixes #25997 `executeNoHooksV3`'s `ideType` handler dereferences the target symbol's type without nil checks, so nimsuggest (v3/v4) dies with SIGSEGV on a `type` query for any symbol without a usable type: - a **void proc** — `s.sym.typ[0]` (the return-type slot) is nil, e.g. "goto type definition" on the `add` in `s.add('x')`; - a **module symbol** — `s.sym.typ` is nil, e.g. a `type` query on the module name in an `import` statement. Both are one editor action away for any user whose client maps `textDocument/typeDefinition` to `type` (nimlangserver does), and the crash takes down the whole nimsuggest process. Root-caused from recurring nimlangserver crash reports by replaying a live session log; reproduced deterministically with a two-line file. The fix guards the derefs and returns an empty result for symbols with no type, matching the existing "bad type" behavior. Two regression cases are appended to `nimsuggest/tests/tv3_typeDefinition.nim` (appended at the end so the existing `$1`–`$4` line-number expectations are untouched); both crash with `SIGSEGV: Illegal storage access` before the fix and pass after. The existing `$3` generic case covers the guarded `elif` branch.