I know this is a compiler regression when using Nim devel.
But I cannot pinpoint or how to reproduce without chronos.
This issue is to remind us because we often use Opt[T] and Option[T] as return type.
Conditions to reproduce:
One of the asymc proc params should be generic type
The return type is Opt[seq[T]] or Option[seq[T]]
It's an async proc
import
std/options,
chronos,
results
type
BID = string or uint64
proc apple(blockId: BID): Future[Option[seq[int]]] {.async.} =
result = options.none(seq[int])
proc banana(blockId: BID): Future[Opt[seq[int]]] {.async.} =
result = Opt.none(seq[int])
let x = waitFor apple("latest")
let y = waitFor banana("latest")
error messages:
...bug.nim(12, 21) template/generic instantiation of `musk` from here
...bug.nim(9, 39) Error: cannot instantiate Option [type declared in ...nim\lib\pure\options.nim(91, 3)]
got: <T>
but expected: <T>
Plain functions like this compiles fine, don't know what happened inside async proc to cause compilation failure.
proc apple(blockId: BID): Option[seq[int]] =
result = options.none(seq[int])
I know this is a compiler regression when using Nim devel. But I cannot pinpoint or how to reproduce without chronos. This issue is to remind us because we often use
Opt[T]
andOption[T]
as return type.Conditions to reproduce:
Opt[seq[T]]
orOption[seq[T]]
error messages:
Plain functions like this compiles fine, don't know what happened inside async proc to cause compilation failure.