nim-chronos icon indicating copy to clipboard operation
nim-chronos copied to clipboard

Its impossible to specify Future[T].Raising([]) as argument.

Open cheatfate opened this issue 2 months ago • 0 comments

Following example is impossible to compile

import chronos

func foo*[T](future: Future[T].Raising([])): bool =
  false

when isMainModule:
  let resFut = Future[void].Raising([CancelledError]).init()
  echo foo(resFut)

It will generate an error:

testraisesarg.nim(3, 31) Error: type mismatch: got <typedesc[Future[foo.T]], array[0..-1, empty]>
but expected one of:
macro Raising[T](F: typedesc[Future[T]]; E: typed): untyped
  first type mismatch at position: 1
  required type for F: typedesc[Future[Raising.T]]
  but expression 'Future[T]' is of type: typedesc[Future[foo.T]]

expression: Raising(Future[T], [])

In such way it become impossible to work with Futures as arguments.

cheatfate avatar Apr 12 '24 11:04 cheatfate