always mangle local variables (#24681)

ref #24677
This commit is contained in:
ringabout
2025-02-20 06:03:58 +08:00
committed by GitHub
parent 91e8e605d0
commit 1af88a2d20
5 changed files with 15 additions and 4 deletions

View File

@@ -115,7 +115,7 @@ proc fillLocalName(p: BProc; s: PSym) =
if s.kind == skTemp:
# speed up conflict search for temps (these are quite common):
if counter != 0: result.add "_" & rope(counter+1)
elif counter != 0 or isKeyword(s.name) or p.module.g.config.cppDefines.contains(key):
elif s.kind != skResult:
result.add "_" & rope(counter+1)
p.sigConflicts.inc(key)
s.loc.snippet = result

View File

@@ -1,5 +1,5 @@
discard """
ccodecheck: "'Result[(i - 0)] = eqdup'"
ccodecheck: "'Result[(i_1 - 0)] = eqdup'"
"""
# issue #24626

View File

@@ -1,7 +1,7 @@
discard """
matrix: "--mm:refc"
output: "Hello"
ccodecheck: "\\i@'a = ((NimStringDesc*) NIM_NIL)'"
ccodecheck: "\\i@'a_1 = ((NimStringDesc*) NIM_NIL)'"
"""
proc main() =

View File

@@ -1,7 +1,7 @@
discard """
output: "1"
cmd: r"nim c --hints:on $options --mm:refc -d:release $file"
ccodecheck: "'NI volatile state;'"
ccodecheck: "'NI volatile state_1;'"
targets: "c"
"""

View File

@@ -45,3 +45,14 @@ block: # bug #22354
main()
proc main = # bug #24677
let NULL = 1
doAssert NULL == 1
var COMMA = 1
doAssert COMMA == 1
for NDEBUG in 0..2:
doAssert NDEBUG == NDEBUG
main()