Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes SI-6559 - StringContext not using passed in escape function.

As reported by Curtis Stanford, with indication of what to fix.  standardInterpolator was not correctly
calling the passed in process function, so raw strings were not really raw.
  • Loading branch information...
commit 492cbe5eec2df5d3e3a4310cf0fda5b86855299f 1 parent 34d021a
@jsuereth jsuereth authored
View
2  src/library/scala/StringContext.scala
@@ -120,7 +120,7 @@ case class StringContext(parts: String*) {
val bldr = new java.lang.StringBuilder(process(pi.next()))
while (ai.hasNext) {
bldr append ai.next
- bldr append treatEscapes(pi.next())
+ bldr append process(pi.next())
}
bldr.toString
}
View
17 test/files/run/t6559.scala
@@ -0,0 +1,17 @@
+
+object Test {
+
+ def main(args: Array[String]) = {
+ val one = "1"
+ val two = "2"
+
+ val raw = raw"\n$one\n$two\n"
+ val escaped = s"\n$one\n$two\n"
+ val buggy = "\\n1\n2\n"
+ val correct = "\\n1\\n2\\n"
+
+ assert(raw != escaped, "Raw strings should not be escaped.")
+ assert(raw != buggy, "Raw strings after variables should not be escaped.")
+ assert(raw == correct, "Raw strings should stay raw.")
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.