Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,12 @@ object Parsers {
syntaxError(msg, offset)
skip(stopAtComma = true)

def syntaxErrorOrIncomplete(msg: Message, span: Span): Unit =
if (in.token == EOF) incompleteInputError(msg)
else
syntaxError(msg, span)
skip(stopAtComma = true)

/** Consume one token of the specified type, or
* signal an error if it is not there.
*
Expand Down Expand Up @@ -2003,7 +2009,7 @@ object Parsers {
handler match {
case Block(Nil, EmptyTree) =>
assert(handlerStart != -1)
syntaxError(
syntaxErrorOrIncomplete(
EmptyCatchBlock(body),
Span(handlerStart, endOffset(handler))
)
Expand Down
10 changes: 10 additions & 0 deletions compiler/test/dotty/tools/repl/ReplCompilerTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,14 @@ class ReplVerboseTests extends ReplTest(ReplTest.defaultOptions :+ "-verbose"):
run("val a = 42")
assert(storedOutput().trim().endsWith("val a: Int = 42"))
}

@Test def `i4393-incomplete-catch`: Unit = contextually {
assert(ParseResult.isIncomplete("""|try {
| ???
|} catch""".stripMargin))
assert(ParseResult.isIncomplete("""|try {
| ???
|} catch {""".stripMargin))
}

end ReplVerboseTests