diff --git a/compiler/renderer.nim b/compiler/renderer.nim index 3d260f350a..1ca5a41e3f 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -51,6 +51,8 @@ type config*: ConfigRef mangler: seq[PSym] +proc renderTree*(n: PNode, renderFlags: TRenderFlags = {}): string + # We render the source code in a two phases: The first # determines how long the subtree will likely be, the second # phase appends to a buffer that will be the output. @@ -1314,9 +1316,23 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) = put(g, tkOpr, "[]") of nkAccQuoted: put(g, tkAccent, "`") - if n.len > 0: gsub(g, n[0]) - for i in 1.. 0 and tmp[0] in {'a'..'z', 'A'..'Z'}: + # handle `=destroy`, `'big' + discard + else: + useSpace = true + elif i > 0: useSpace = true + if useSpace: put(g, tkSpaces, Space) gsub(g, n[i]) put(g, tkAccent, "`") of nkIfExpr: diff --git a/tests/stdlib/trepr.nim b/tests/stdlib/trepr.nim index 357854d671..bca9b9f918 100644 --- a/tests/stdlib/trepr.nim +++ b/tests/stdlib/trepr.nim @@ -145,5 +145,23 @@ do: do: 4""" + block: # bug #17292 (bug 4) + let a = deb: + proc `=destroy`() = discard + proc `'foo`(): int = discard + proc `foo bar baz`(): int = discard + let a2 = """ + +proc `=destroy`() = + discard + +proc `'foo`(): int = + discard + +proc `foo bar baz`(): int = + discard +""" + doAssert a2 == a + static: main() main()