tasync_noasync.nim 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. discard """
  2. cmd: "nim check --hints:off --warnings:off $file"
  3. action: "reject"
  4. nimout: '''
  5. tasync_noasync.nim(21, 10) Error: Can only 'await' inside a proc marked as 'async'. Use 'waitFor' when calling an 'async' proc in a non-async scope instead
  6. tasync_noasync.nim(25, 12) Error: Can only 'await' inside a proc marked as 'async'. Use 'waitFor' when calling an 'async' proc in a non-async scope instead
  7. tasync_noasync.nim(28, 10) Error: Can only 'await' inside a proc marked as 'async'. Use 'waitFor' when calling an 'async' proc in a non-async scope instead
  8. tasync_noasync.nim(31, 10) Error: Can only 'await' inside a proc marked as 'async'. Use 'waitFor' when calling an 'async' proc in a non-async scope instead
  9. tasync_noasync.nim(35, 10) Error: Can only 'await' inside a proc marked as 'async'. Use 'waitFor' when calling an 'async' proc in a non-async scope instead
  10. tasync_noasync.nim(38, 10) Error: Can only 'await' inside a proc marked as 'async'. Use 'waitFor' when calling an 'async' proc in a non-async scope instead
  11. tasync_noasync.nim(40, 8) Error: Can only 'await' inside a proc marked as 'async'. Use 'waitFor' when calling an 'async' proc in a non-async scope instead
  12. '''
  13. """
  14. import async
  15. proc a {.async.} =
  16. discard
  17. # Bad await usage
  18. proc nonAsyncProc =
  19. await a()
  20. proc nestedNonAsyncProc {.async.} =
  21. proc nested =
  22. await a()
  23. iterator customIterator: int =
  24. await a()
  25. macro awaitInMacro =
  26. await a()
  27. type DummyRef = ref object of RootObj
  28. method awaitInMethod(_: DummyRef) {.base.} =
  29. await a()
  30. proc improperMultisync {.multisync.} =
  31. await a()
  32. await a()
  33. # if we overload a fallback handler to get
  34. # await only available within {.async.}
  35. # we would need `{.dirty.}` templates for await