asyncmacro: add nnkSym support for getName() (#9204)

Fixes #9201
This commit is contained in:
alaviss
2018-10-09 20:53:13 +07:00
committed by Andreas Rumpf
parent 8a1055adce
commit 2a31f42d35
2 changed files with 15 additions and 1 deletions

View File

@@ -190,7 +190,7 @@ proc getName(node: NimNode): string {.compileTime.} =
case node.kind
of nnkPostfix:
return node[1].strVal
of nnkIdent:
of nnkIdent, nnkSym:
return node.strVal
of nnkEmpty:
return "anonymous"

14
tests/async/t9201.nim Normal file
View File

@@ -0,0 +1,14 @@
discard """
exitcode: 0
"""
# Derived from issue #9201
import asyncdispatch, macros
macro newAsyncProc(name: untyped): untyped =
expectKind name, nnkStrLit
let pName = genSym(nskProc, name.strVal)
result = getAst async quote do:
proc `pName`() = discard
newAsyncProc("hello")