Skip to content

Commit

Permalink
Fixes a nimsuggest crash when using chronos
Browse files Browse the repository at this point in the history
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.}
```
  • Loading branch information
jmgomez committed Feb 7, 2024
1 parent 4b67ccc commit 524fd09
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/semtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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}:
Expand Down

0 comments on commit 524fd09

Please sign in to comment.