Skip to content

Commit 1206a81

Browse files
committed
PatternMatcher: fix bug with undefined variable inside huge patterns.
1 parent ebe3290 commit 1206a81

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
464464
// all potentially stored subpat binders
465465
val potentiallyStoredBinders = stored.unzip._1.toSet
466466
// compute intersection of all symbols in the tree `in` and all potentially stored subpat binders
467-
new DeepFolder[Unit]((x: Unit, t:Tree) => if (potentiallyStoredBinders(t.symbol)) usedBinders += t.symbol).apply((), in)
467+
new DeepFolder[Unit]((x: Unit, t:Tree) =>
468+
if (potentiallyStoredBinders(t.symbol)) usedBinders += t.symbol).apply((), in)
468469

469470
if (usedBinders.isEmpty) in
470471
else {
@@ -1440,9 +1441,8 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
14401441
// require (nbSubPats > 0 && (!lastIsStar || isSeq))
14411442
protected def subPatRefs(binder: Symbol): List[Tree] = {
14421443
val refs = if (totalArity > 0 && isSeq) subPatRefsSeq(binder)
1443-
else if (defn.isProductSubType(binder.info)) productElemsToN(binder, totalArity)
1444+
else if (totalArity > 1 && !isSeq) productElemsToN(binder, totalArity)
14441445
else ref(binder):: Nil
1445-
val refsSymbols = refs.map(_.symbol) // just for debugging
14461446
refs
14471447
}
14481448

0 commit comments

Comments
 (0)