File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -280,6 +280,12 @@ object Parsers {
280280 syntaxError(msg, offset)
281281 skip(stopAtComma = true )
282282
283+ def syntaxErrorOrIncomplete (msg : Message , span : Span ): Unit =
284+ if (in.token == EOF ) incompleteInputError(msg)
285+ else
286+ syntaxError(msg, span)
287+ skip(stopAtComma = true )
288+
283289 /** Consume one token of the specified type, or
284290 * signal an error if it is not there.
285291 *
@@ -2003,7 +2009,7 @@ object Parsers {
20032009 handler match {
20042010 case Block (Nil , EmptyTree ) =>
20052011 assert(handlerStart != - 1 )
2006- syntaxError (
2012+ syntaxErrorOrIncomplete (
20072013 EmptyCatchBlock (body),
20082014 Span (handlerStart, endOffset(handler))
20092015 )
Original file line number Diff line number Diff line change @@ -300,4 +300,14 @@ class ReplVerboseTests extends ReplTest(ReplTest.defaultOptions :+ "-verbose"):
300300 run(" val a = 42" )
301301 assert(storedOutput().trim().endsWith(" val a: Int = 42" ))
302302 }
303+
304+ @ Test def `i4393-incomplete-catch` : Unit = contextually {
305+ assert(ParseResult .isIncomplete(""" |try {
306+ | ???
307+ |} catch""" .stripMargin))
308+ assert(ParseResult .isIncomplete(""" |try {
309+ | ???
310+ |} catch {""" .stripMargin))
311+ }
312+
303313end ReplVerboseTests
You can’t perform that action at this time.
0 commit comments