diff --git a/chronos/asyncmacro2.nim b/chronos/asyncmacro2.nim index 7860a9f6..7439c3be 100644 --- a/chronos/asyncmacro2.nim +++ b/chronos/asyncmacro2.nim @@ -77,10 +77,9 @@ proc cleanupOpenSymChoice(node: NimNode): NimNode {.compileTime.} = # ref https://github.com/nim-lang/Nim/issues/11091 if node.kind in nnkCallKinds and node[0].kind == nnkOpenSymChoice and node[0].eqIdent("[]"): - result = newNimNode(nnkBracketExpr).add( - cleanupOpenSymChoice(node[1]), - cleanupOpenSymChoice(node[2]) - ) + result = newNimNode(nnkBracketExpr) + for child in node[1..^1]: + result.add(cleanupOpenSymChoice(child)) else: result = node.copyNimNode() for child in node: diff --git a/tests/testmacro.nim b/tests/testmacro.nim index fadda826..705ec2d9 100644 --- a/tests/testmacro.nim +++ b/tests/testmacro.nim @@ -97,3 +97,10 @@ suite "Macro transformations test suite": type OpenObject = object macroAsync(testMacro, seq, OpenObject) 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