@@ -249,11 +249,11 @@ object Parsers {
249249
250250 /** Skip on error to next safe point.
251251 */
252- protected def skip (): Unit =
252+ protected def skip (stopAtComma : Boolean ): Unit =
253253 val lastRegion = in.currentRegion
254254 def atStop =
255255 in.token == EOF
256- || skipStopTokens.contains(in.token) && (in.currentRegion eq lastRegion)
256+ || ((stopAtComma && in.token == COMMA ) || skipStopTokens.contains(in.token) ) && (in.currentRegion eq lastRegion)
257257 while ! atStop do
258258 in.nextToken()
259259 lastErrorOffset = in.offset
@@ -278,7 +278,7 @@ object Parsers {
278278 if (in.token == EOF ) incompleteInputError(msg)
279279 else
280280 syntaxError(msg, offset)
281- skip()
281+ skip(stopAtComma = true )
282282
283283 /** Consume one token of the specified type, or
284284 * signal an error if it is not there.
@@ -346,7 +346,7 @@ object Parsers {
346346 false // it's a statement that might be legal in an outer context
347347 else
348348 in.nextToken() // needed to ensure progress; otherwise we might cycle forever
349- skip()
349+ skip(stopAtComma = false )
350350 true
351351
352352 in.observeOutdented()
@@ -881,7 +881,8 @@ object Parsers {
881881 val next = in.lookahead.token
882882 next == LBRACKET || next == LPAREN
883883
884- /** Is current ident a `*`, and is it followed by a `)` or `, )`? */
884+ /** Is current ident a `*`, and is it followed by a `)`, `, )`, `,EOF`? The latter two are not
885+ syntactically valid, but we need to include them here for error recovery. */
885886 def followingIsVararg (): Boolean =
886887 in.isIdent(nme.raw.STAR ) && {
887888 val lookahead = in.LookaheadScanner ()
@@ -890,7 +891,7 @@ object Parsers {
890891 || lookahead.token == COMMA
891892 && {
892893 lookahead.nextToken()
893- lookahead.token == RPAREN
894+ lookahead.token == RPAREN || lookahead.token == EOF
894895 }
895896 }
896897
0 commit comments