fix: pattern variables cannot shadow each other

This commit is contained in:
Leonardo de Moura 2021-01-16 08:23:45 -08:00
parent 7e0d76aff0
commit eb25b97501
2 changed files with 10 additions and 4 deletions

View file

@ -188,9 +188,15 @@ private def skippingBinders {α} (numParams : Nat) (x : Array Name → DelabM α
where
loop : Nat → Array Name → DelabM α
| 0, varNames => x varNames
| n+1, varNames =>
withBindingBodyUnusedName fun id => do
loop n (varNames.push id.getId)
| n+1, varNames => do
let varName ← (← getExpr).bindingName!.eraseMacroScopes
-- Pattern variables cannot shadow each other
if varNames.contains varName then
let varName := (← getLCtx).getUnusedName varName
loop n (varNames.push varName)
else
withBindingBodyUnusedName fun id => do
loop n (varNames.push id.getId)
/--
Delaborate applications of "matchers" such as

View file

@ -34,7 +34,7 @@ fun (x : Nat × Nat) =>
fun (x x_1 : Option Nat) =>
match x, x_1 with
| some a, some b => some (a + b)
| x, x => none : Option Nat → Option Nat → Option Nat
| x, x_2 => fun (x : Option Nat) => none : Option Nat → Option Nat → Option Nat
fun (x : Nat) =>
(match x with
| 0 => id