diff options
author | Paul Phillips <paulp@improving.org> | 2012-09-01 09:33:26 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-09-01 22:40:43 -0700 |
commit | ce048745e1520c03cd1467933a87f4d5f8b77652 (patch) | |
tree | ce9f2554f2131e7a4dac9e9d6064a7a6a8f05e7f | |
parent | 6b87cdcd7bd6d1932e87e6bf8dc6029d6461a488 (diff) | |
download | scala-ce048745e1520c03cd1467933a87f4d5f8b77652.tar.gz scala-ce048745e1520c03cd1467933a87f4d5f8b77652.tar.bz2 scala-ce048745e1520c03cd1467933a87f4d5f8b77652.zip |
Fix for SI-6273, repl string interpolation.
As usual the hard part is tracing through all the
needless abstraction. Begone, 25 layers of parsing error
issuing methods!
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 8 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t5510.check | 2 | ||||
-rw-r--r-- | test/files/run/t6273.check | 19 | ||||
-rw-r--r-- | test/files/run/t6273.scala | 11 |
5 files changed, 38 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index e6bf43fe93..dd0f8fdbe0 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -754,8 +754,12 @@ trait Scanners extends ScannersCommon { } else { 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 { + if (multiLine) + incompleteInputError("unclosed multi-line string literal") + else + syntaxError("unclosed string literal") + } + else { putChar(ch) nextRawChar() getStringPart(multiLine) diff --git a/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala b/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala index f49e8d6b59..0f5777d260 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala @@ -37,7 +37,7 @@ trait ExprTyper { } /** Parse a line into a sequence of trees. Returns None if the input is incomplete. */ - def parse(line: String): Option[List[Tree]] = { + def parse(line: String): Option[List[Tree]] = debugging(s"""parse("$line")""") { var isIncomplete = false reporter.withIncompleteHandler((_, _) => isIncomplete = true) { val trees = codeParser.stmts(line) diff --git a/test/files/neg/t5510.check b/test/files/neg/t5510.check index 60da3bed40..04220e79bb 100644 --- a/test/files/neg/t5510.check +++ b/test/files/neg/t5510.check @@ -13,7 +13,7 @@ t5510.scala:5: error: unclosed string literal t5510.scala:6: error: unclosed multi-line string literal val s5 = ""s""" $s1 $s2 s" ^ -t5510.scala:7: error: '}' expected but eof found. +t5510.scala:7: error: unclosed multi-line string literal } ^ 6 errors found diff --git a/test/files/run/t6273.check b/test/files/run/t6273.check new file mode 100644 index 0000000000..c1c18daac2 --- /dev/null +++ b/test/files/run/t6273.check @@ -0,0 +1,19 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> val y = 55 +y: Int = 55 + +scala> val x = s""" + y = $y +""" +x: String = +" + y = 55 +" + +scala> + +scala> diff --git a/test/files/run/t6273.scala b/test/files/run/t6273.scala new file mode 100644 index 0000000000..ed0fd452e0 --- /dev/null +++ b/test/files/run/t6273.scala @@ -0,0 +1,11 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def tq = "\"\"\"" + def code = s""" +val y = 55 +val x = s$tq + y = $$y +$tq + """ +} |