diff options
author | alaviss <alaviss@users.noreply.github.com> | 2018-10-09 20:53:13 +0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-10-09 15:53:13 +0200 |
commit | 2a31f42d35121e12dfbef368ce9d5d1751aa1376 (patch) | |
tree | d09dabe7ae346f69499c3959e69f58548c74d8b7 | |
parent | 8a1055adcea8847e1cb2fae87c84d06afa3198b1 (diff) | |
download | Nim-2a31f42d35121e12dfbef368ce9d5d1751aa1376.tar.gz |
asyncmacro: add nnkSym support for getName() (#9204)
Fixes #9201
-rw-r--r-- | lib/pure/asyncmacro.nim | 2 | ||||
-rw-r--r-- | tests/async/t9201.nim | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/pure/asyncmacro.nim b/lib/pure/asyncmacro.nim index 9acd4bd79..b18d20d55 100644 --- a/lib/pure/asyncmacro.nim +++ b/lib/pure/asyncmacro.nim @@ -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" diff --git a/tests/async/t9201.nim b/tests/async/t9201.nim new file mode 100644 index 000000000..5aaba7063 --- /dev/null +++ b/tests/async/t9201.nim @@ -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") |