Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed Mar 30, 2021
1 parent 4c122d1 commit c90644e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/ccgtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ proc mangleParamName(m: BModule; s: PSym): Rope =
## we cannot use 'sigConflicts' here since we have a BModule, not a BProc.
## Fortunately C's scoping rules are sane enough so that that doesn't
## cause any trouble.
if s.name.s == "_":
result = getTempName(m)
return
result = s.loc.r
if result == nil:
var res = s.name.s.mangle
Expand Down
23 changes: 23 additions & 0 deletions tests/proc/tunderscore.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
discard """
targets: "c cpp js"
"""

var x = 0

block:
proc foo(_, _: int) = x += 5

foo(1, 2)
doAssert x == 5

block:
proc foo(_: int, _: float) = x += 5

foo(1, 2)
doAssert x == 10

block:
proc foo(_: int, _: float, _: string) = x += 5

foo(1, 2, "5")
doAssert x == 15

0 comments on commit c90644e

Please sign in to comment.