mirror of
https://github.com/logos-storage/nim-chronos.git
synced 2026-01-09 00:43:09 +00:00
Handle multiple childs for opensymchoice (#266)
And more tests. Follow up of #261
This commit is contained in:
parent
5a906ad56c
commit
ae19d5b6f0
@ -77,10 +77,9 @@ proc cleanupOpenSymChoice(node: NimNode): NimNode {.compileTime.} =
|
|||||||
# ref https://github.com/nim-lang/Nim/issues/11091
|
# ref https://github.com/nim-lang/Nim/issues/11091
|
||||||
if node.kind in nnkCallKinds and
|
if node.kind in nnkCallKinds and
|
||||||
node[0].kind == nnkOpenSymChoice and node[0].eqIdent("[]"):
|
node[0].kind == nnkOpenSymChoice and node[0].eqIdent("[]"):
|
||||||
result = newNimNode(nnkBracketExpr).add(
|
result = newNimNode(nnkBracketExpr)
|
||||||
cleanupOpenSymChoice(node[1]),
|
for child in node[1..^1]:
|
||||||
cleanupOpenSymChoice(node[2])
|
result.add(cleanupOpenSymChoice(child))
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
result = node.copyNimNode()
|
result = node.copyNimNode()
|
||||||
for child in node:
|
for child in node:
|
||||||
|
|||||||
@ -97,3 +97,10 @@ suite "Macro transformations test suite":
|
|||||||
type OpenObject = object
|
type OpenObject = object
|
||||||
macroAsync(testMacro, seq, OpenObject)
|
macroAsync(testMacro, seq, OpenObject)
|
||||||
check waitFor(testMacro()).len == 0
|
check waitFor(testMacro()).len == 0
|
||||||
|
|
||||||
|
macro macroAsync2(name, restype, inner1, inner2, inner3, inner4: untyped): untyped =
|
||||||
|
quote do:
|
||||||
|
proc `name`(): Future[`restype`[`inner1`[`inner2`[`inner3`, `inner4`]]]] {.async.} = return
|
||||||
|
|
||||||
|
macroAsync2(testMacro2, seq, Opt, Result, OpenObject, cstring)
|
||||||
|
check waitFor(testMacro2()).len == 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user