Skip to content

Commit 53bbb78

Browse files
committed
fix(16459): add patch to syntax error
Add patch to cover the cornercase where xml pattern in parens confuse the parser. I'm not confident that this change is 100% safe...
1 parent 4b0fff5 commit 53bbb78

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,7 @@ object Parsers {
928928
lookahead.nextToken()
929929
while (parens != 0 && lookahead.token != EOF) {
930930
val token = lookahead.token
931+
if (token == XMLSTART) return true
931932
if (token == LPAREN) parens += 1
932933
else if (token == RPAREN) parens -= 1
933934
lookahead.nextToken()

tests/run/i16459.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ object Test {
5454
// Pattern match with if guard.
5555
// Note: This passes in Scala 2.12.18 and 2.13.12 too.
5656
val auxiliary8 = for (case _ @ <foo>FooBar</foo> <- Seq(xml) if true)
57+
yield ()
5758
// Note: These pass in Scala 2.12.18 and 2.13.12.
5859
val auxiliary9 = for (case _ @ <foo>FooBar</foo><- Seq(xml) if true)
60+
yield ()
5961
val auxiliary10 = for (case _ @ <foo>FooBar</foo><-Seq(xml) if true)
60-
yield ()
62+
yield ()
6163

6264
}
6365

0 commit comments

Comments
 (0)