fix: getMatchWithExtra
`getMatchKeyArgs` returns arguments in reverse order.
This commit is contained in:
parent
4a8679a57c
commit
1282fb2d97
2 changed files with 19 additions and 5 deletions
|
|
@ -483,15 +483,20 @@ partial def getMatchWithExtra (d : DiscrTree α) (e : Expr) : MetaM (Array (α
|
|||
let (k, args) ← getMatchKeyArgs e (root := true)
|
||||
match k with
|
||||
| Key.star => return result
|
||||
| _ => process k args 0 result
|
||||
| _ => process k args.toSubarray 0 result
|
||||
where
|
||||
process (k : Key) (args : Array Expr) (numExtraArgs : Nat) (result : Array (α × Nat)) : MetaM (Array (α × Nat)) := do
|
||||
let result := result ++ ((← getMatchRoot d k args #[]).map (., numExtraArgs))
|
||||
process (k : Key) (args : Subarray Expr) (numExtraArgs : Nat) (result : Array (α × Nat)) : MetaM (Array (α × Nat)) := do
|
||||
-- Remark: the args are stored in reverse order
|
||||
let result :=
|
||||
if d.root.find? k |>.isSome then
|
||||
result ++ ((← getMatchRoot d k args.toArray #[]).map (., numExtraArgs))
|
||||
else
|
||||
result
|
||||
match k with
|
||||
| Key.const f 0 => return result
|
||||
| Key.const f (n+1) => process (Key.const f n) args.pop (numExtraArgs + 1) result
|
||||
| Key.const f (n+1) => process (Key.const f n) args.popFront (numExtraArgs + 1) result
|
||||
| Key.fvar f 0 => return result
|
||||
| Key.fvar f (n+1) => process (Key.fvar f n) args.pop (numExtraArgs + 1) result
|
||||
| Key.fvar f (n+1) => process (Key.fvar f n) args.popFront (numExtraArgs + 1) result
|
||||
| _ => return result
|
||||
|
||||
partial def getUnify (d : DiscrTree α) (e : Expr) : MetaM (Array α) :=
|
||||
|
|
|
|||
9
tests/lean/run/simpPartialApp.lean
Normal file
9
tests/lean/run/simpPartialApp.lean
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
variable {U V}
|
||||
|
||||
def f : (U → V) → (U → U) := sorry
|
||||
def add {U} : U → U → U := sorry
|
||||
|
||||
@[simp] theorem foo (u : U) : f (add u) = id := sorry
|
||||
|
||||
def bar (u v : U) : f (add u) v = id v := by
|
||||
simp
|
||||
Loading…
Add table
Reference in a new issue