diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 2c848aa5728e..22717aff41ad 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -194,7 +194,7 @@ object Parsers { def isNumericLit = numericLitTokens contains in.token def isTemplateIntro = templateIntroTokens contains in.token def isDclIntro = dclIntroTokens contains in.token - def isStatSeqEnd = in.isNestedEnd || in.token == EOF + def isStatSeqEnd = in.isNestedEnd || in.token == EOF || in.token == RPAREN def mustStartStat = mustStartStatTokens contains in.token /** Is current token a hard or soft modifier (in modifier position or not)? */ diff --git a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala index d89a5479d0d2..825cf2aca003 100644 --- a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala +++ b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala @@ -1274,7 +1274,7 @@ class ErrorMessagesTests extends ErrorMessagesTest { checkMessagesAfter(FrontEnd.name) { """ |object Test { - | { ) } + | { with } | { private ) } |} """.stripMargin diff --git a/tests/neg/i4934.scala b/tests/neg/i4934.scala index 597f684f54d7..22b07ff5e7d0 100644 --- a/tests/neg/i4934.scala +++ b/tests/neg/i4934.scala @@ -1,10 +1,11 @@ -object Foo { - val a = ""); // error: end of statement expected -} // From #5824: object Main { def main(args: Array[String]): Unit = { val foo = 123 ""; // error: end of statement expected println(foo) } -} \ No newline at end of file +} + +object Foo { + val a = ""); // error: `}` expected but `)` found +} // error: eof expected diff --git a/tests/neg/parser-stability-4.scala b/tests/neg/parser-stability-4.scala index 41be1b692022..5c3466faba5e 100644 --- a/tests/neg/parser-stability-4.scala +++ b/tests/neg/parser-stability-4.scala @@ -1,3 +1,2 @@ class x0{ def x0: x0 = (x0 => x0) => x0) // error // error -// error \ No newline at end of file diff --git a/tests/pos/i7998.scala b/tests/pos/i7998.scala new file mode 100644 index 000000000000..50eeb8df4ba2 --- /dev/null +++ b/tests/pos/i7998.scala @@ -0,0 +1,6 @@ +@main def Test = + ( + try 1 + catch + case _: Throwable => 2 + ) \ No newline at end of file