mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
* fixes #15804
* fix the existing test
* add the testcase for #15804
Co-authored-by: narimiran <narimiran@disroot.org>
(cherry picked from commit dfd8a83f35)
This commit is contained in:
15
tests/async/t15804.nim
Normal file
15
tests/async/t15804.nim
Normal file
@@ -0,0 +1,15 @@
|
||||
import asyncdispatch
|
||||
|
||||
type
|
||||
Foo*[E] = ref object
|
||||
op: proc(): Future[bool] {.gcsafe.}
|
||||
|
||||
proc newFoo*[E](): Foo[E] =
|
||||
result = Foo[E]()
|
||||
result.op = proc(): Future[bool] {.gcsafe,async.} =
|
||||
await sleepAsync(100)
|
||||
result = false
|
||||
|
||||
when isMainModule:
|
||||
let f = newFoo[int]()
|
||||
echo waitFor f.op()
|
||||
@@ -1,7 +1,7 @@
|
||||
discard """
|
||||
errormsg: "undeclared identifier: 'await'"
|
||||
errormsg: "'yield' only allowed in an iterator"
|
||||
cmd: "nim c $file"
|
||||
file: "tasync_noasync.nim"
|
||||
file: "asyncmacro.nim"
|
||||
"""
|
||||
import async
|
||||
|
||||
@@ -12,4 +12,4 @@ await a()
|
||||
|
||||
# if we overload a fallback handler to get
|
||||
# await only available within {.async.}
|
||||
# we would need `{.dirty.}` templates for await
|
||||
# we would need `{.dirty.}` templates for await
|
||||
|
||||
Reference in New Issue
Block a user