File tree 2 files changed +17
-1
lines changed
src/dotty/tools/dotc/parsing
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -280,6 +280,12 @@ object Parsers {
280
280
syntaxError(msg, offset)
281
281
skip(stopAtComma = true )
282
282
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
+
283
289
/** Consume one token of the specified type, or
284
290
* signal an error if it is not there.
285
291
*
@@ -2003,7 +2009,7 @@ object Parsers {
2003
2009
handler match {
2004
2010
case Block (Nil , EmptyTree ) =>
2005
2011
assert(handlerStart != - 1 )
2006
- syntaxError (
2012
+ syntaxErrorOrIncomplete (
2007
2013
EmptyCatchBlock (body),
2008
2014
Span (handlerStart, endOffset(handler))
2009
2015
)
Original file line number Diff line number Diff line change @@ -300,4 +300,14 @@ class ReplVerboseTests extends ReplTest(ReplTest.defaultOptions :+ "-verbose"):
300
300
run(" val a = 42" )
301
301
assert(storedOutput().trim().endsWith(" val a: Int = 42" ))
302
302
}
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
+
303
313
end ReplVerboseTests
You can’t perform that action at this time.
0 commit comments