Skip to content

Commit 2c63ee3

Browse files
committed
Don't stop at commas when trying to find the end of a statement.
1 parent fb73f4b commit 2c63ee3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ object Tokens extends TokensCommon {
285285

286286
final val endMarkerTokens = identifierTokens | BitSet(IF, WHILE, FOR, MATCH, TRY, NEW, THROW, GIVEN, VAL, THIS)
287287

288-
final val skipStopTokens = BitSet(SEMI, NEWLINE, NEWLINES, RBRACE, RPAREN, RBRACKET, OUTDENT, COMMA)
288+
final val skipStopTokens = BitSet(SEMI, NEWLINE, NEWLINES, RBRACE, RPAREN, RBRACKET, OUTDENT)
289289

290290
final val softModifierNames = Set(nme.inline, nme.opaque, nme.open, nme.transparent, nme.infix)
291291
}

0 commit comments

Comments
 (0)