summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala3
-rw-r--r--test/files/neg/illegal-stmt-start.check4
-rw-r--r--test/files/neg/illegal-stmt-start.scala5
3 files changed, 11 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 1cfee481bc..497cfc398b 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -2630,7 +2630,8 @@ self =>
} else if (isStatSep) {
in.nextToken()
} else {
- syntaxErrorOrIncomplete("illegal start of statement", true)
+ val addendum = if (isModifier) " (no modifiers allowed here)" else ""
+ syntaxErrorOrIncomplete("illegal start of statement" + addendum, true)
}
}
stats.toList
diff --git a/test/files/neg/illegal-stmt-start.check b/test/files/neg/illegal-stmt-start.check
new file mode 100644
index 0000000000..01747524f8
--- /dev/null
+++ b/test/files/neg/illegal-stmt-start.check
@@ -0,0 +1,4 @@
+illegal-stmt-start.scala:3: error: illegal start of statement (no modifiers allowed here)
+ private def bar {}
+ ^
+one error found
diff --git a/test/files/neg/illegal-stmt-start.scala b/test/files/neg/illegal-stmt-start.scala
new file mode 100644
index 0000000000..48ae0a8b0a
--- /dev/null
+++ b/test/files/neg/illegal-stmt-start.scala
@@ -0,0 +1,5 @@
+class Test {
+ def foo {
+ private def bar {}
+ }
+} \ No newline at end of file