Skip to content

Commit

Permalink
Escape _ in term names to make it not interfere with mangling. Fixes #…
Browse files Browse the repository at this point in the history
…374 (#389)

* Escape _ in term names to make it not interfere with mangling. Fixes #374
* Fix type in generated file's name
  • Loading branch information
ragnr authored and densh committed Nov 16, 2016
1 parent 58f9dfa commit e843653
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ lazy val tests =
.split("/")
.mkString(".")
}.filter(_ != "tests.Suite").mkString("Seq(", ", ", ")")
val file = (sourceManaged in Compile).value / "tests" / "Disover.scala"
val file = (sourceManaged in Compile).value / "tests" / "Discover.scala"
IO.write(file,
s"""
package tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ trait NirNameEncoding { self: NirCodeGen =>
owner member ("init" +: mangledParams).mkString("_")
} else {
val mangledRetty = mangledType(tpe.resultType, retty = true)
owner member (id +: (mangledParams :+ mangledRetty)).mkString("_")
owner member (id.replace("_", "__") +: (mangledParams :+ mangledRetty))
.mkString("_")
}
}

Expand Down
11 changes: 11 additions & 0 deletions unit-tests/src/main/scala/scala/scalanative/issues/_374Suite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package scala.scalanative.issues

object _374Suite extends tests.Suite {
test("#374") {
assert("42" == bar(42))
assert("bar" == bar_i32())
}

def bar(i: Int): String = i.toString
def bar_i32(): String = "bar"
}

0 comments on commit e843653

Please sign in to comment.