Skip to content

Commit

Permalink
fix(16459): add patch to syntax error
Browse files Browse the repository at this point in the history
Add patch to cover the cornercase where xml pattern in parens confuse
the parser.

I'm not confident that this change is 100% safe...
  • Loading branch information
i10416 committed Jan 25, 2024
1 parent 4b0fff5 commit 53bbb78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@ object Parsers {
lookahead.nextToken()
while (parens != 0 && lookahead.token != EOF) {
val token = lookahead.token
if (token == XMLSTART) return true
if (token == LPAREN) parens += 1
else if (token == RPAREN) parens -= 1
lookahead.nextToken()
Expand Down
4 changes: 3 additions & 1 deletion tests/run/i16459.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ object Test {
// Pattern match with if guard.
// Note: This passes in Scala 2.12.18 and 2.13.12 too.
val auxiliary8 = for (case _ @ <foo>FooBar</foo> <- Seq(xml) if true)
yield ()
// Note: These pass in Scala 2.12.18 and 2.13.12.
val auxiliary9 = for (case _ @ <foo>FooBar</foo><- Seq(xml) if true)
yield ()
val auxiliary10 = for (case _ @ <foo>FooBar</foo><-Seq(xml) if true)
yield ()
yield ()

}

Expand Down

0 comments on commit 53bbb78

Please sign in to comment.