fixes a bug for 'dup' and 'with'; they can now handle nested statement lists that can result from macros

This commit is contained in:
Araq 2020-03-17 11:22:20 +01:00
commit b737bb4be0
3 changed files with 22 additions and 25 deletions

View file

@ -35,14 +35,7 @@ macro with*(arg: typed; calls: varargs[untyped]): untyped =
doAssert a == 43
result = newNimNode(nnkStmtList, arg)
expectKind calls, nnkArgList
let body =
if calls.len == 1 and calls[0].kind in {nnkStmtList, nnkStmtListExpr}:
calls[0]
else:
calls
for call in body:
result.add underscoredCall(call, arg)
underscoredCalls(result, calls, arg)
when isMainModule:
type