From 4cb50f160c4a108f034e5e84f378452d2403c2ef Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 15 Jan 2020 16:50:47 +0100 Subject: [PATCH 1/3] Fix #7998: Treat `)` as token that can end a statement --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 2 +- tests/pos/i7998.scala | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i7998.scala 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/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 From 79c0cb61f19d3fa1904d809e2daba9cb15b353a1 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 18 Jan 2020 11:00:07 +0100 Subject: [PATCH 2/3] Fix tests --- tests/neg/i4934.scala | 9 +++++---- tests/neg/parser-stability-4.scala | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) 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 From 1a3cc72c3cd4a404953b380943f55b586dfcbeeb Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 18 Jan 2020 13:21:22 +0100 Subject: [PATCH 3/3] Fix error message test --- .../test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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