From bb930aef2d43343aee49c15c16a6e29827982152 Mon Sep 17 00:00:00 2001 From: metagn Date: Wed, 23 Aug 2023 14:43:02 +0300 Subject: [PATCH] don't render underscore identifiers with id (#22538) (cherry picked from commit 4f891aa50c298bcb81fc8859e2118b3118188720) --- compiler/renderer.nim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/renderer.nim b/compiler/renderer.nim index b9c3268c4c..20540ec61e 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -14,7 +14,7 @@ {.used.} import - lexer, options, idents, strutils, ast, msgs, lineinfos + lexer, options, idents, strutils, ast, msgs, lineinfos, wordrecg when defined(nimPreviewSlimSystem): import std/[syncio, assertions, formatfloat] @@ -848,7 +848,7 @@ proc gcase(g: var TSrcGen, n: PNode) = gsub(g, n[^1], c) proc genSymSuffix(result: var string, s: PSym) {.inline.} = - if sfGenSym in s.flags: + if sfGenSym in s.flags and s.name.id != ord(wUnderscore): result.add '_' result.addInt s.id @@ -971,7 +971,9 @@ proc gident(g: var TSrcGen, n: PNode) = s.addInt localId if sfCursor in n.sym.flags: s.add "_cursor" - elif n.kind == nkSym and (renderIds in g.flags or sfGenSym in n.sym.flags or n.sym.kind == skTemp): + elif n.kind == nkSym and (renderIds in g.flags or + (sfGenSym in n.sym.flags and n.sym.name.id != ord(wUnderscore)) or + n.sym.kind == skTemp): s.add '_' s.addInt n.sym.id when defined(debugMagics):