Skip to content

Commit 030d95e

Browse files
authored
Merge pull request #8019 from dotty-staging/fix-#7998
Fix #7998: Treat `)` as token that can end a statement
2 parents 3768984 + 1a3cc72 commit 030d95e

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ object Parsers {
194194
def isNumericLit = numericLitTokens contains in.token
195195
def isTemplateIntro = templateIntroTokens contains in.token
196196
def isDclIntro = dclIntroTokens contains in.token
197-
def isStatSeqEnd = in.isNestedEnd || in.token == EOF
197+
def isStatSeqEnd = in.isNestedEnd || in.token == EOF || in.token == RPAREN
198198
def mustStartStat = mustStartStatTokens contains in.token
199199

200200
/** Is current token a hard or soft modifier (in modifier position or not)? */

compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ class ErrorMessagesTests extends ErrorMessagesTest {
12741274
checkMessagesAfter(FrontEnd.name) {
12751275
"""
12761276
|object Test {
1277-
| { ) }
1277+
| { with }
12781278
| { private ) }
12791279
|}
12801280
""".stripMargin

tests/neg/i4934.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
object Foo {
2-
val a = ""); // error: end of statement expected
3-
}
41
// From #5824:
52
object Main {
63
def main(args: Array[String]): Unit = {
74
val foo = 123 ""; // error: end of statement expected
85
println(foo)
96
}
10-
}
7+
}
8+
9+
object Foo {
10+
val a = ""); // error: `}` expected but `)` found
11+
} // error: eof expected

tests/neg/parser-stability-4.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
class x0{
22
def x0: x0 = (x0 => x0) => x0) // error // error
3-
// error

tests/pos/i7998.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@main def Test =
2+
(
3+
try 1
4+
catch
5+
case _: Throwable => 2
6+
)

0 commit comments

Comments
 (0)