From 524fd09760df2e0980bf3cb8dbcae8396ff608de Mon Sep 17 00:00:00 2001 From: jmgomez Date: Wed, 7 Feb 2024 11:33:27 +0000 Subject: [PATCH] Fixes a nimsuggest crash when using chronos The following would crash nimsuggest on init: ``` import chronos type HistoryQuery = object start: int limit: int HistoryResult = object messages: string type HistoryQueryHandler* = proc(req: HistoryQuery): Future[HistoryResult] {.async, gcsafe.} ``` --- compiler/semtypes.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index ebc0b1dbc8e57..6cb90589223da 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -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}: