summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala10
-rw-r--r--test/files/run/interpreter.check19
-rw-r--r--test/files/run/interpreter.scala7
3 files changed, 35 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 51b53dff76..d81b31904c 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -92,6 +92,9 @@ trait Parsers {
private def stringVal = inName.toString
private def inNextTokenCode = in.next.token
+ /** whether a non-continuable error has been seen */
+ private var nonContinuableError = false
+
/** the markup parser */
def xmlp = {
if (xmlp0 == null)
@@ -178,6 +181,7 @@ trait Parsers {
skip()
in.skipping = false
}
+ nonContinuableError = true
}
def syntaxErrorMigrate(msg: String) =
@@ -190,7 +194,11 @@ trait Parsers {
}
def incompleteInputError(pos: ScanPosition, msg: String) {
- if (pos != in.errpos) {
+ if (pos == in.errpos) return
+
+ if (nonContinuableError)
+ syntaxError(pos, msg, false)
+ else {
in.incompleteInputError(pos, msg)
in.errpos = pos
}
diff --git a/test/files/run/interpreter.check b/test/files/run/interpreter.check
index be5e7c7dd9..90745ee56f 100644
--- a/test/files/run/interpreter.check
+++ b/test/files/run/interpreter.check
@@ -133,3 +133,22 @@ scala> two: Int = 2
scala>
scala>
+scala>
+scala>
+scala> <console>:1: error: '=' expected but '=>' found.
+def x => y => z
+ ^
+<console>:1: error: illegal start of simple expression
+def x => y => z
+ ^
+
+scala> <console>:1: error: identifier expected but integer literal found.
+[1,2,3]
+ ^
+<console>:1: error: ']' expected but eof found.
+[1,2,3]
+ ^
+
+scala>
+scala>
+scala>
diff --git a/test/files/run/interpreter.scala b/test/files/run/interpreter.scala
index 22dbf4754d..c59ce9f758 100644
--- a/test/files/run/interpreter.scala
+++ b/test/files/run/interpreter.scala
@@ -75,6 +75,13 @@ val x20 = 1
val two = one + x5
+
+// interior syntax errors should *not* go into multi-line input mode.
+// both of the following should abort immediately:
+def x => y => z
+[1,2,3]
+
+
</code>.text