Skip to content

Commit

Permalink
Merge pull request #1616 from retronym/backport/6559
Browse files Browse the repository at this point in the history
SI-6559 Fix raw string interpolator: string parts which were after the first argument were still escaped
  • Loading branch information
adriaanm committed Nov 16, 2012
2 parents 83deccf + 88b4b91 commit 813fa70
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/library/scala/StringContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/rawstrings.check
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[\n\t'"$]
[\n\t'"$\n]
2 changes: 1 addition & 1 deletion test/files/run/rawstrings.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
object Test extends App {
println(raw"[\n\t'${'"'}$$]")
println(raw"[\n\t'${'"'}$$\n]")
}
17 changes: 17 additions & 0 deletions test/files/run/t6559.scala
Original file line number Diff line number Diff line change
@@ -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.