Skip to content

Commit 7b35ce9

Browse files
ringaboutnarimiran
authored andcommitted
fix NimNode comment repr() regression [backport: 1.2] (#19726)
(cherry picked from commit 15ae932)
1 parent 0798bd0 commit 7b35ce9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

compiler/renderer.nim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ proc putNL(g: var TSrcGen) =
150150
proc optNL(g: var TSrcGen, indent: int) =
151151
g.pendingNL = indent
152152
g.lineLen = indent
153+
g.col = g.indent
153154
when defined(nimpretty): g.pendingNewlineCount = 0
154155

155156
proc optNL(g: var TSrcGen) =
@@ -158,6 +159,7 @@ proc optNL(g: var TSrcGen) =
158159
proc optNL(g: var TSrcGen; a, b: PNode) =
159160
g.pendingNL = g.indent
160161
g.lineLen = g.indent
162+
g.col = g.indent
161163
when defined(nimpretty): g.pendingNewlineCount = lineDiff(a, b)
162164

163165
proc indentNL(g: var TSrcGen) =

tests/macros/tmacros1.nim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,22 @@ macro foo(t: static Tuple): untyped =
6060
doAssert t.b == 12345
6161

6262
foo((a: "foo", b: 12345))
63+
64+
65+
# bug #16307
66+
67+
macro bug(x: untyped): string =
68+
newLit repr(x)
69+
70+
let res = bug:
71+
block:
72+
## one
73+
## two
74+
## three
75+
76+
doAssert res == """
77+
78+
block:
79+
## one
80+
## two
81+
## three"""

0 commit comments

Comments
 (0)