Browse files

Merge pull request #1616 from retronym/backport/6559

SI-6559 Fix raw string interpolator: string parts which were after the first argument were still escaped
  • Loading branch information...
2 parents 83deccf + 88b4b91 commit 813fa70c71e55ab8eb3d5f909c12cb417f2b30e4 @adriaanm adriaanm committed Nov 16, 2012
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
2 test/files/run/rawstrings.check
@@ -1 +1 @@
-[\n\t'"$]
+[\n\t'"$\n]
View
2 test/files/run/rawstrings.scala
@@ -1,3 +1,3 @@
object Test extends App {
- println(raw"[\n\t'${'"'}$$]")
+ println(raw"[\n\t'${'"'}$$\n]")
}
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.")
+ }
+}

0 comments on commit 813fa70

Please sign in to comment.