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

@ -216,14 +216,7 @@ when (NimMajor, NimMinor) >= (1, 1):
result = newNimNode(nnkStmtListExpr, arg)
let tmp = genSym(nskVar, "dupResult")
result.add newVarStmt(tmp, 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, tmp)
underscoredCalls(result, calls, tmp)
result.add tmp