Fix void async in templates (#17562)
* Fix https://github.com/nim-lang/Nim/issues/16159 * Add test for async in template * Shorten the expression * Even shorter Co-authored-by: Clyybber <darkmine956@gmail.com>
This commit is contained in:
parent
a672ec3c9e
commit
9e88425d7c
2 changed files with 15 additions and 2 deletions
|
|
@ -184,8 +184,9 @@ proc asyncSingleProc(prc: NimNode): NimNode =
|
||||||
verifyReturnType(repr(returnType), returnType)
|
verifyReturnType(repr(returnType), returnType)
|
||||||
|
|
||||||
let subtypeIsVoid = returnType.kind == nnkEmpty or
|
let subtypeIsVoid = returnType.kind == nnkEmpty or
|
||||||
(baseType.kind == nnkIdent and returnType[1].eqIdent("void"))
|
(baseType.kind in {nnkIdent, nnkSym} and
|
||||||
|
baseType.eqIdent("void"))
|
||||||
|
|
||||||
let futureVarIdents = getFutureVarIdents(prc.params)
|
let futureVarIdents = getFutureVarIdents(prc.params)
|
||||||
|
|
||||||
var outerProcBody = newNimNode(nnkStmtList, prc.body)
|
var outerProcBody = newNimNode(nnkStmtList, prc.body)
|
||||||
|
|
|
||||||
12
tests/async/tasyncintemplate.nim
Normal file
12
tests/async/tasyncintemplate.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
discard """
|
||||||
|
output: 42
|
||||||
|
"""
|
||||||
|
|
||||||
|
import asyncdispatch
|
||||||
|
|
||||||
|
template foo() =
|
||||||
|
proc temp(): Future[int] {.async.} = return 42
|
||||||
|
proc tempVoid(): Future[void] {.async.} = echo await temp()
|
||||||
|
|
||||||
|
foo()
|
||||||
|
waitFor tempVoid()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue