From 8cc36cdfa17c26a55ab1d164105363f3492f72af Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Wed, 29 Feb 2012 12:51:18 +0100 Subject: Fixes SI-5530 --- src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 2626ca26a6..20360b547e 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -698,12 +698,15 @@ trait Scanners extends ScannersCommon { } else { syntaxError("invalid string interpolation") } - } else if ((ch == CR || ch == LF || ch == SU) && !isUnicodeEscape) { - syntaxError("unclosed string literal") } else { - putChar(ch) - nextRawChar() - getStringPart(multiLine) + val isUnclosedLiteral = !isUnicodeEscape && (ch == SU || (!multiLine && (ch == CR || ch == LF))) + if (isUnclosedLiteral) { + syntaxError(if (!multiLine) "unclosed string literal" else "unclosed multi-line string literal") + } else { + putChar(ch) + nextRawChar() + getStringPart(multiLine) + } } } -- cgit v1.2.3 From c1e76ddb80cf7737bfe0e8c99e70ee2ace66e43e Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Thu, 1 Mar 2012 09:59:42 +0100 Subject: Fixes SI-5532 --- src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 14 ++++++++++---- test/files/run/t5532.flags | 1 + test/files/run/t5532.scala | 4 ++++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 test/files/run/t5532.flags create mode 100644 test/files/run/t5532.scala (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 2626ca26a6..9d33e7e9e1 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -670,12 +670,18 @@ trait Scanners extends ScannersCommon { next.offset = charOffset - 1 } if (ch == '"') { - nextRawChar() - if (!multiLine || isTripleQuote()) { + if (multiLine) { + nextRawChar() + if (isTripleQuote()) { + setStrVal() + token = STRINGLIT + } else + getStringPart(multiLine) + } else { + nextChar() setStrVal() token = STRINGLIT - } else - getStringPart(multiLine) + } } else if (ch == '$') { nextRawChar() if (ch == '$') { diff --git a/test/files/run/t5532.flags b/test/files/run/t5532.flags new file mode 100644 index 0000000000..e1b37447c9 --- /dev/null +++ b/test/files/run/t5532.flags @@ -0,0 +1 @@ +-Xexperimental \ No newline at end of file diff --git a/test/files/run/t5532.scala b/test/files/run/t5532.scala new file mode 100644 index 0000000000..75004730bf --- /dev/null +++ b/test/files/run/t5532.scala @@ -0,0 +1,4 @@ +object Test extends App { + val x = s"1" + val y = s"2" +} \ No newline at end of file -- cgit v1.2.3