Nim icon indicating copy to clipboard operation
Nim copied to clipboard

Renderer doesn't escape/quote symbols when it should

Open yglukhov opened this issue 2 years ago • 2 comments

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

yglukhov avatar Apr 19 '22 09:04 yglukhov

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.

Yardanico avatar May 27 '22 18:05 Yardanico

This should not have a Codegen label

metagn avatar Aug 09 '22 04:08 metagn