diff options
author | Lukas Rytz <lukas.rytz@typesafe.com> | 2015-08-24 11:43:35 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@typesafe.com> | 2015-08-24 11:43:35 +0200 |
commit | 3d62009a8e2e715fe12981e7c72c5a701ce6bf96 (patch) | |
tree | 0ce88e1e4780d8f04d371f67c3e1400ffb819220 /test/files | |
parent | 3a543d64158e85b65f8998460c832362bdddec4f (diff) | |
parent | ab527ce8cc0220443bda5cc3337ebae158c2fe74 (diff) | |
download | scala-3d62009a8e2e715fe12981e7c72c5a701ce6bf96.tar.gz scala-3d62009a8e2e715fe12981e7c72c5a701ce6bf96.tar.bz2 scala-3d62009a8e2e715fe12981e7c72c5a701ce6bf96.zip |
Merge pull request #4590 from som-snytt/issue/6810
SI-6810 Disallow EOL in char literal
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/t6810.check | 28 | ||||
-rw-r--r-- | test/files/neg/t6810.scala | 26 |
2 files changed, 54 insertions, 0 deletions
diff --git a/test/files/neg/t6810.check b/test/files/neg/t6810.check new file mode 100644 index 0000000000..497ef35070 --- /dev/null +++ b/test/files/neg/t6810.check @@ -0,0 +1,28 @@ +t6810.scala:4: error: unclosed character literal + val y = ' + ^ +t6810.scala:5: error: unclosed character literal +' // but not embedded EOL sequences not represented as escapes +^ +t6810.scala:9: error: unclosed string literal + val Y = " + ^ +t6810.scala:10: error: unclosed string literal +" // obviously not +^ +t6810.scala:20: error: unclosed quoted identifier + val ` + ^ +t6810.scala:21: error: unclosed quoted identifier +` = EOL // not raw string literals aka triple-quoted, multiline strings +^ +t6810.scala:24: error: unclosed character literal + val b = ' + ^ +t6810.scala:25: error: unclosed character literal +' // CR seen as EOL by scanner +^ +t6810.scala:24: error: '=' expected but ';' found. + val b = ' +^ +9 errors found diff --git a/test/files/neg/t6810.scala b/test/files/neg/t6810.scala new file mode 100644 index 0000000000..50c305d70c --- /dev/null +++ b/test/files/neg/t6810.scala @@ -0,0 +1,26 @@ + +trait t6810 { + val x = '\u000A' // char literals accept arbitrary unicode escapes + val y = ' +' // but not embedded EOL sequences not represented as escapes + val z = '\n' // normally, expect this escape + + val X = "\u000A" // it's the same as ordinary string literals + val Y = " +" // obviously not + val Z = "\n" // normally, expect this escape + + val A = """ +""" // which is what these are for + val B = s""" +""" // or the same for interpolated strings + + import scala.compat.Platform.EOL + val `\u000A` = EOL // backquoted identifiers are arbitrary string literals + val ` +` = EOL // not raw string literals aka triple-quoted, multiline strings + + val a = '\u000D' // similar treatment of CR + val b = '
' // CR seen as EOL by scanner + val c = '\r' // traditionally +} |