t20111.nim 402 B

1234567891011121314151617181920
  1. discard """
  2. action: "run"
  3. """
  4. import asyncdispatch
  5. type
  6. Sync = object
  7. Async = object
  8. SyncRes = (Sync, string)
  9. AsyncRes = (Async, string)
  10. proc foo(val: Sync | Async): Future[(Async, string) | (Sync, string)] {.multisync.} =
  11. return (val, "hello")
  12. let
  13. myAsync = Async()
  14. mySync = Sync()
  15. doAssert typeof(waitFor foo(myAsync)) is AsyncRes
  16. doAssert typeof(foo(mySync)) is SyncRes