From 855492c928a795f175c6bb10ee6d4b23c871a123 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Mon, 2 Jan 2017 22:19:09 -0800 Subject: SI-10133 Require escaped single quote char lit The spec specifically requires `'\''` and not `'''`. The error consumes all consecutive single quotes. --- src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/compiler') 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 == '\'') { -- cgit v1.2.3