diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2021-03-23 00:34:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-23 08:34:04 +0100 |
commit | f3a642710989c3f47d5c2131efd69e3dbfedc336 (patch) | |
tree | 0c40c0727e41a95e1701a28292b6b99b4b9edfee /compiler | |
parent | d78ebe4a0eadb889255c77f6e375ecec9c706f19 (diff) | |
download | Nim-f3a642710989c3f47d5c2131efd69e3dbfedc336.tar.gz |
refs #17292 fix `repr` with `do:` (#17449)
* refs #17292 fix `repr` with `do:` * address comment
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/renderer.nim | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/compiler/renderer.nim b/compiler/renderer.nim index 13ff6941f..c36eaaf11 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -1007,12 +1007,19 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) = of nkCall, nkConv, nkDotCall, nkPattern, nkObjConstr: if n.len > 1 and n.lastSon.kind in {nkStmtList, nkStmtListExpr}: accentedName(g, n[0]) - if n.len > 2: + var i = 1 + while i < n.len and n[i].kind notin {nkStmtList, nkStmtListExpr}: i.inc + if i > 1: put(g, tkParLe, "(") - gcomma(g, n, 1, -2) + gcomma(g, n, 1, i - 1 - n.len) put(g, tkParRi, ")") put(g, tkColon, ":") - gsub(g, n, n.len-1) + gsub(g, n, i) + for j in i+1 ..< n.len: + optNL(g) + put(g, tkDo, "do") + put(g, tkColon, ":") + gsub(g, n, j) elif n.len >= 1: case bracketKind(g, n[0]) of bkBracket: |