summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2017-01-02 22:19:09 -0800
committerSom Snytt <som.snytt@gmail.com>2017-01-08 01:07:21 -0800
commit855492c928a795f175c6bb10ee6d4b23c871a123 (patch)
tree1bfc1893405790a2758f75b04692acdddadb26e2 /src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
parentbf9b00ebede9ab16fc4662a3dd5f5fb5d6a5ab7c (diff)
downloadscala-855492c928a795f175c6bb10ee6d4b23c871a123.tar.gz
scala-855492c928a795f175c6bb10ee6d4b23c871a123.tar.bz2
scala-855492c928a795f175c6bb10ee6d4b23c871a123.zip
SI-10133 Require escaped single quote char lit
The spec specifically requires `'\''` and not `'''`. The error consumes all consecutive single quotes.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Scanners.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index a8cc7f91c2..54c604c072 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -538,6 +538,11 @@ trait Scanners extends ScannersCommon {
charLitOr(getIdentRest)
else if (isOperatorPart(ch) && (ch != '\\'))
charLitOr(getOperatorRest)
+ else if (ch == '\'') {
+ nextChar()
+ val advice = if (ch == '\'') { do nextChar() while (ch == '\''); " (use '\\'' for single quote)" } else ""
+ syntaxError(s"empty character literal${advice}")
+ }
else if (!isAtEnd && (ch != SU && ch != CR && ch != LF || isUnicodeEscape)) {
getLitChar()
if (ch == '\'') {