Skip to content

Commit 4286e2d

Browse files
committed
Merge pull request scala#4214 from som-snytt/issue/5154
SI-5154 Parse leading literal brace in XML pattern
2 parents 89cf671 + 4d96a8a commit 4286e2d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,10 @@ trait MarkupParsers {
425425
if (ch != '/') ts append xPattern // child
426426
else return false // terminate
427427

428-
case '{' => // embedded Scala patterns
429-
while (ch == '{') {
430-
nextch()
428+
case '{' if xCheckEmbeddedBlock => // embedded Scala patterns, if not double brace
429+
do {
431430
ts ++= xScalaPatterns
432-
}
431+
} while (xCheckEmbeddedBlock)
433432
assert(!xEmbeddedBlock, "problem with embedded block")
434433

435434
case SU =>

test/files/pos/t5154.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
trait Z {
3+
// extra space made the pattern OK
4+
def f = <z> {{3}}</z> match { case <z> {{3}}</z> => }
5+
6+
// lack of space: error: illegal start of simple pattern
7+
def g = <z>{{3}}</z> match { case <z>{{3}}</z> => }
8+
}
9+

0 commit comments

Comments
 (0)