fix: pattern normalization code
This commit is contained in:
parent
95cf18457d
commit
eddcedb58c
2 changed files with 17 additions and 13 deletions
|
|
@ -477,19 +477,7 @@ partial def normalize (e : Expr) : M Expr := do
|
|||
normalize eNew
|
||||
else
|
||||
matchConstCtor e.getAppFn
|
||||
(fun _ => do
|
||||
if (← isProof e) then
|
||||
/- We mark nested proofs as inaccessible. This is fine due to proof irrelevance.
|
||||
We need this feature to be able to elaborate definitions such as:
|
||||
```
|
||||
def f : Fin 2 → Nat
|
||||
| 0 => 5
|
||||
| 1 => 45
|
||||
```
|
||||
-/
|
||||
return mkInaccessible (← eraseInaccessibleAnnotations (← instantiateMVars e))
|
||||
else
|
||||
throwInvalidPattern e)
|
||||
(fun _ => return mkInaccessible (← eraseInaccessibleAnnotations (← instantiateMVars e)))
|
||||
(fun v us => do
|
||||
let args := e.getAppArgs
|
||||
unless args.size == v.numParams + v.numFields do
|
||||
|
|
|
|||
16
tests/lean/run/finDotCtor.lean
Normal file
16
tests/lean/run/finDotCtor.lean
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
def get : (as : List α) → (i : Fin as.length) → α
|
||||
| a::as, .mk 0 _ => a
|
||||
| a::as, .mk (i+1) h => get as (.mk i (Nat.lt_of_succ_lt_succ h))
|
||||
|
||||
namespace Ex
|
||||
|
||||
inductive Fin : Nat → Type
|
||||
| zero : Fin (.succ n)
|
||||
| succ : Fin n → Fin (.succ n)
|
||||
deriving Repr
|
||||
|
||||
def get : (as : List α) → (i : Fin as.length) → α
|
||||
| a::as, .zero => a
|
||||
| a::as, .succ i => get as i
|
||||
|
||||
end Ex
|
||||
Loading…
Add table
Reference in a new issue