Skip to content

Commit

Permalink
asyncmacro: add nnkSym support for getName() (nim-lang#9204)
Browse files Browse the repository at this point in the history
  • Loading branch information
alaviss authored and krux02 committed Oct 15, 2018
1 parent b1d4fa4 commit ba30000
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pure/asyncmacro.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 14 additions & 0 deletions tests/async/t9201.nim
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit ba30000

Please sign in to comment.