Skip to content

Commit c079e05

Browse files
committed
save before commit
1 parent 43f448f commit c079e05

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/Lean/Elab/BindersUtil.lean

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,18 @@ def getMatchAltsNumPatterns (matchAlts : Syntax) : Nat :=
4444
let pats := alt0[1][0].getSepArgs
4545
pats.size
4646

47+
open TSyntax.Compat in
4748
/--
4849
Expand a match alternative such as `| 0 | 1 => rhs` to an array containing `| 0 => rhs` and `| 1 => rhs`.
4950
-/
5051
def expandMatchAlt (stx : TSyntax ``matchAlt) : MacroM (Array (TSyntax ``matchAlt)) :=
51-
match stx with
52-
| `(matchAltExpr| | $[$patss,*]|* => $rhs) =>
53-
if patss.size ≤ 1 then
54-
return #[stx]
55-
else
56-
patss.mapM fun pats => `(matchAltExpr| | $pats,* => $rhs)
57-
| _ => return #[stx]
52+
-- Not using syntax quotations here to keep source location
53+
-- of the pattern sequence (`$term,*`) intact
54+
let patss := stx.raw[1].getSepArgs
55+
if patss.size ≤ 1 then
56+
return #[stx]
57+
else
58+
return patss.map fun pats => stx.raw.setArg 1 (mkNullNode #[pats])
5859

5960
def shouldExpandMatchAlt : TSyntax ``matchAlt → Bool
6061
| `(matchAltExpr| | $[$patss,*]|* => $_) => patss.size > 1

src/Lean/Elab/Match.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def getMatchAlt : Syntax → Option MatchAltView
165165
| alt@`(matchAltExpr| | $patterns,* => $rhs) => some {
166166
ref := alt,
167167
patterns := patterns,
168-
lhs := alt[1],
168+
lhs := alt[1], -- this is the ref `$patterns,*`
169169
rhs := rhs
170170
}
171171
| _ => none

0 commit comments

Comments
 (0)