Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: kernel exception from fvars left from
?m a b
instantiation (le…
…anprover#4410) Closes leanprover#4375 The following example raises `error: (kernel) declaration has free variables '_example'`: ```lean example: Nat → Nat := let a : Nat := Nat.zero fun (_ : Nat) => let b : Nat := Nat.zero (fun (_ : a = b) => 0) (Eq.refl a) ``` During elaboration of `0`, `elabNumLit` creates a synthetic mvar `?_uniq.16` which gets abstracted by `elabFun` to `?_uniq.16 := ?_uniq.50 _uniq.6 _uniq.12`. The `isDefEq` to `instOfNatNat 0` results in: ``` ?_uniq.50 := fun ([email protected]._hyg.13 : Nat) => let b : Nat := Nat.zero fun ([email protected]._hyg.23 : Eq.{1} Nat _uniq.4 b) => instOfNatNat 0 ``` This has a free variable `_uniq.4` which was `a`. When the application of `?_uniq.50` to `#[#2, #0]` is instantiated, the `let b : Nat := Nat.zero` blocks the beta-reduction and `_uniq.4` remains in the expression. fix: add `(useZeta := true)` here: https://github.com/leanprover/lean4/blob/ea46bf2839ad1c98d3a0c3e5caad8a81f812934c/src/Lean/MetavarContext.lean#L567
- Loading branch information