diff options
author | Som Snytt <som.snytt@gmail.com> | 2014-04-27 00:08:54 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2014-07-18 21:07:37 -0700 |
commit | abb58dcef1b4758f4e3af26c030e1f0630b8d145 (patch) | |
tree | 74f61c65e53ce8adfd3e985b4c23fbe9a3986e9b /test/files/neg/t8266-invalid-interp.check | |
parent | abdd570cee5788000724c6d3b89a978c48a7fa39 (diff) | |
download | scala-abb58dcef1b4758f4e3af26c030e1f0630b8d145.tar.gz scala-abb58dcef1b4758f4e3af26c030e1f0630b8d145.tar.bz2 scala-abb58dcef1b4758f4e3af26c030e1f0630b8d145.zip |
SI-6476 Improve error on escapement
Behavior of escape processing under string interpolation can
be confusing. This commit improves the exception message so
you know at least what sort of escapes are handled.
This came up on SO in the form `s"\d".r`, where it may not
be obvious what is throwing and how to work around it.
```
scala> s"\d".r
scala.StringContext$InvalidEscapeException: invalid escape '\d' not one of [\b, \t, \n, \f, \r, \\, \", \'] at index 0 in "\d". Use \\ for literal \.
scala> s"a\"
scala.StringContext$InvalidEscapeException: invalid escape at terminal index 1 in "a\". Use \\ for literal \.
```
Referencing SI-6476 because that has become the magnet ticket
for "escape processing under string interpolation, huh?"
This doesn't address `$"` and doesn't handle the more interesting
parse error `s"a\"b"`.
Diffstat (limited to 'test/files/neg/t8266-invalid-interp.check')
-rw-r--r-- | test/files/neg/t8266-invalid-interp.check | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/test/files/neg/t8266-invalid-interp.check b/test/files/neg/t8266-invalid-interp.check index 70dd4081b0..bb2d44a80c 100644 --- a/test/files/neg/t8266-invalid-interp.check +++ b/test/files/neg/t8266-invalid-interp.check @@ -1,10 +1,10 @@ t8266-invalid-interp.scala:4: error: Trailing '\' escapes nothing. f"a\", ^ -t8266-invalid-interp.scala:5: error: invalid escape character at index 1 in "a\xc" +t8266-invalid-interp.scala:5: error: invalid escape '\x' not one of [\b, \t, \n, \f, \r, \\, \", \'] at index 1 in "a\xc". Use \\ for literal \. f"a\xc", ^ -t8266-invalid-interp.scala:7: error: invalid escape character at index 1 in "a\vc" +t8266-invalid-interp.scala:7: error: invalid escape '\v' not one of [\b, \t, \n, \f, \r, \\, \", \'] at index 1 in "a\vc". Use \\ for literal \. f"a\vc" ^ three errors found |