Nim
Nim copied to clipboard
Renderer doesn't escape/quote symbols when it should
import macros
macro dumpRepr(u: typed) =
echo repr u
template decl(a: untyped) =
proc `a @ procName`(`a @ param`: int) = discard
dumpRepr:
decl(hi)
Actual output:
proc hi@procName(a@param`gensym0: int) =
discard
Expected output:
proc `hi@procName`(`a@param'`'gensym0`: int) =
discard
$ nim -v
Nim Compiler Version 1.7.1 [Linux: amd64]
Compiled at 2022-04-19
Copyright (c) 2006-2022 by Andreas Rumpf
git hash: dc4cc2dca53e3772efb3654a4ddbbe8350d1db43
active boot switches: -d:release
I've briefly looked at the renderer, and it only seems to check the first character of the name to see if it should be quoted or not - https://github.com/nim-lang/Nim/blob/devel/compiler/renderer.nim#L971
It's possible to change this to check the whole string, not just the first character, although I'm not sure if it's the right approach.
This should not have a Codegen label