Fixes a nimsuggest crash when using chronos (#23293)

The following would crash nimsuggest on init:
```nim
import chronos
type
  HistoryQuery = object
    start: int
    limit: int

  HistoryResult = object
    messages: string

type HistoryQueryHandler* = proc(req: HistoryQuery): Future[HistoryResult] {.async, gcsafe.}
```
This commit is contained in:
Juan M Gómez
2024-02-20 06:36:50 +00:00
committed by GitHub
parent 39f2df1972
commit 7bf8cd3f86
2 changed files with 5 additions and 2 deletions

View File

@@ -58,10 +58,9 @@ proc initCandidateSymbols(c: PContext, headSymbol: PNode,
]#
for paramSym in searchInScopesAllCandidatesFilterBy(c, symx.name, {skConst}):
let paramTyp = paramSym.typ
if paramTyp.n.sym.kind in filter:
if paramTyp.n.kind == nkSym and paramTyp.n.sym.kind in filter:
result.add((paramTyp.n.sym, o.lastOverloadScope))
symx = nextOverloadIter(o, c, headSymbol)
if result.len > 0:
best = initCandidate(c, result[0].s, initialBinding,

View File

@@ -2180,6 +2180,10 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
else:
let symKind = if n.kind == nkIteratorTy: skIterator else: skProc
result = semProcTypeWithScope(c, n, prev, symKind)
if result == nil:
localError(c.config, n.info, "type expected, but got: " & renderTree(n))
result = newOrPrevType(tyError, prev, c)
if n.kind == nkIteratorTy and result.kind == tyProc:
result.flags.incl(tfIterator)
if result.callConv == ccClosure and c.config.selectedGC in {gcArc, gcOrc, gcAtomicArc}: