Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SI-6476 Accept backslash at end of interpolation
Everyone wants to say `raw"\hello, world.\"`. Parser accepts arbitrary escaped quotes optionally followed by a quote. That is, an escaped quote is deemed to terminate the interpolated string if it is not followed by another quote on the same line.
- Loading branch information
Showing
7 changed files
with
91 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
string-interpolator.scala:2: error: invalid escape at terminal index 1 in "x\". Use \\ for literal \. | ||
val sa = s"x\"y | ||
^ | ||
string-interpolator.scala:2: error: postfix operator y needs to be enabled | ||
by making the implicit value scala.language.postfixOps visible. | ||
This can be achieved by adding the import clause 'import scala.language.postfixOps' | ||
or by setting the compiler option -language:postfixOps. | ||
See the Scaladoc for value scala.language.postfixOps for a discussion | ||
why the feature needs to be explicitly enabled. | ||
val sa = s"x\"y | ||
^ | ||
2 errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
object Test { | ||
val sa = s"x\"y | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
t5510.scala:2: error: unclosed string literal | ||
t5510.scala:5: error: unclosed string literal | ||
val sb = "x\"y | ||
^ | ||
t5510.scala:6: error: unclosed string literal | ||
val s1 = s"xxx | ||
^ | ||
t5510.scala:3: error: unclosed string literal | ||
t5510.scala:7: error: unclosed string literal | ||
val s2 = s"xxx $x | ||
^ | ||
t5510.scala:4: error: unclosed string literal | ||
t5510.scala:8: error: unclosed string literal | ||
val s3 = s"xxx $$ | ||
^ | ||
t5510.scala:5: error: unclosed string literal | ||
t5510.scala:9: error: unclosed string literal | ||
val s4 = ""s" | ||
^ | ||
t5510.scala:6: error: unclosed multi-line string literal | ||
t5510.scala:10: error: unclosed multi-line string literal | ||
val s5 = ""s""" $s1 $s2 s" | ||
^ | ||
t5510.scala:7: error: unclosed multi-line string literal | ||
t5510.scala:11: error: unclosed multi-line string literal | ||
} | ||
^ | ||
6 errors | ||
7 errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
"Hello", Alice | ||
oh hai C:\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters