Skip to content

Commit 15ae932

Browse files
authored
fix NimNode comment repr() regression [backport: 1.2] (#19726)
1 parent 465fd06 commit 15ae932

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
@@ -165,6 +165,7 @@ proc putNL(g: var TSrcGen) =
165165
proc optNL(g: var TSrcGen, indent: int) =
166166
g.pendingNL = indent
167167
g.lineLen = indent
168+
g.col = g.indent
168169
when defined(nimpretty): g.pendingNewlineCount = 0
169170

170171
proc optNL(g: var TSrcGen) =
@@ -173,6 +174,7 @@ proc optNL(g: var TSrcGen) =
173174
proc optNL(g: var TSrcGen; a, b: PNode) =
174175
g.pendingNL = g.indent
175176
g.lineLen = g.indent
177+
g.col = g.indent
176178
when defined(nimpretty): g.pendingNewlineCount = lineDiff(a, b)
177179

178180
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)