Skip to content

Commit

Permalink
always mangle local variables (nim-lang#24681)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout authored Feb 19, 2025
1 parent 91e8e60 commit 1af88a2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compiler/ccgtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/arc/tnodestroyexplicithook.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
ccodecheck: "'Result[(i - 0)] = eqdup'"
ccodecheck: "'Result[(i_1 - 0)] = eqdup'"
"""

# issue #24626
Expand Down
2 changes: 1 addition & 1 deletion tests/ccgbugs/tassign_nil_strings.nim
Original file line number Diff line number Diff line change
@@ -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() =
Expand Down
2 changes: 1 addition & 1 deletion tests/ccgbugs/tmissingvolatile.nim
Original file line number Diff line number Diff line change
@@ -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"
"""

Expand Down
11 changes: 11 additions & 0 deletions tests/ccgbugs2/tcodegen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 1af88a2

Please sign in to comment.