@@ -162,10 +162,10 @@ private def getMatchGeneralizing? : Syntax → Option Bool
162162
163163/-- Given the `stx` of a single match alternative, return a corresponding `MatchAltView`. -/
164164def getMatchAlt : Syntax → Option MatchAltView
165- | alt@`(matchAltExpr| | $patterns:matchAltPats => $rhs) => some {
165+ | alt@`(matchAltExpr| | $patterns,* => $rhs) => some {
166166 ref := alt,
167- patterns := patterns.raw[ 0 ].getSepArgs ,
168- lhs := patterns ,
167+ patterns := patterns,
168+ lhs := alt[ 1 ] ,
169169 rhs := rhs
170170 }
171171 | _ => none
@@ -759,13 +759,13 @@ end ToDepElimPattern
759759def withDepElimPatterns (patternVarDecls : Array PatternVarDecl) (ps : Array Expr) (matchType : Expr) (k : Array LocalDecl → Array Pattern → Expr → TermElabM α) : TermElabM α := do
760760 ToDepElimPattern.main patternVarDecls ps matchType k
761761
762- private def withElaboratedLHS {α} (patternVarDecls : Array PatternVarDecl) (patternStxs : Array Syntax) (lhsStx : Syntax) (numDiscrs : Nat) (matchType : Expr)
762+ private def withElaboratedLHS {α} (ref : Syntax) ( patternVarDecls : Array PatternVarDecl) (patternStxs : Array Syntax) (lhsStx : Syntax) (numDiscrs : Nat) (matchType : Expr)
763763 (k : AltLHS → Expr → TermElabM α) : ExceptT PatternElabException TermElabM α := do
764764 let (patterns, matchType) ← withSynthesize <| withRef lhsStx <| elabPatterns patternStxs numDiscrs matchType
765765 id (α := TermElabM α) do
766766 trace[Elab.match] "patterns: {patterns}"
767767 withDepElimPatterns patternVarDecls patterns matchType fun localDecls patterns matchType => do
768- k { ref := lhsStx , fvarDecls := localDecls.toList, patterns := patterns.toList } matchType
768+ k { ref := ref , fvarDecls := localDecls.toList, patterns := patterns.toList } matchType
769769
770770/--
771771 Try to clear the free variables in `toClear` and auxiliary discriminants, and then execute `k` in the updated local context.
@@ -817,7 +817,7 @@ private def elabMatchAltView (discrs : Array Discr) (alt : MatchAltView) (matchT
817817 let (patternVars, alt) ← collectPatternVars alt
818818 trace[Elab.match] "patternVars: {patternVars}"
819819 withPatternVars patternVars fun patternVarDecls => do
820- withElaboratedLHS patternVarDecls alt.patterns alt.lhs discrs.size matchType fun altLHS matchType =>
820+ withElaboratedLHS alt.ref patternVarDecls alt.patterns alt.lhs discrs.size matchType fun altLHS matchType =>
821821 withEqs discrs altLHS.patterns fun eqs =>
822822 withLocalInstances altLHS.fvarDecls do
823823 trace[Elab.match] "elabMatchAltView: {matchType}"
0 commit comments