Skip to content

Commit 492cbe5

Browse files
committed
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.
1 parent 34d021a commit 492cbe5

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/library/scala/StringContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ case class StringContext(parts: String*) {
120120
val bldr = new java.lang.StringBuilder(process(pi.next()))
121121
while (ai.hasNext) {
122122
bldr append ai.next
123-
bldr append treatEscapes(pi.next())
123+
bldr append process(pi.next())
124124
}
125125
bldr.toString
126126
}

test/files/run/t6559.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
object Test {
3+
4+
def main(args: Array[String]) = {
5+
val one = "1"
6+
val two = "2"
7+
8+
val raw = raw"\n$one\n$two\n"
9+
val escaped = s"\n$one\n$two\n"
10+
val buggy = "\\n1\n2\n"
11+
val correct = "\\n1\\n2\\n"
12+
13+
assert(raw != escaped, "Raw strings should not be escaped.")
14+
assert(raw != buggy, "Raw strings after variables should not be escaped.")
15+
assert(raw == correct, "Raw strings should stay raw.")
16+
}
17+
}

0 commit comments

Comments
 (0)