lean4-htt/tests/lean/run/meta5.lean
JovanGerb b894464191
fix: type occurs check bug (#6128)
This PR does the same fix as #6104, but such that it doesn't break the
test/the file in `Plausible`. This is done by not creating unused let
binders in metavariable types that are made by `elimMVar`. (This is also
a positive thing for users looking at metavariable types, for example in
error messages)

We get rid of `skipAtMostNumBinders`. This function was originally
defined for the purpose of making this test work, but it is a hack
because it allows cycles in the metavariable context.

It would make sense to split these changes into 2 PRs, but I combined
them here to show that the combination of them closes #6013 without
breaking anything

Closes #6013
2024-11-21 00:28:36 +00:00

38 lines
902 B
Text

import Lean.Meta
open Lean
open Lean.Meta
def tst1 : MetaM Unit :=
withLocalDeclD `y (mkConst `Nat) $ fun y => do
withLetDecl `x (mkConst `Nat) (mkNatLit 0) $ fun x => do {
let mvar ← mkFreshExprMVar (mkConst `Nat) MetavarKind.syntheticOpaque;
trace[Meta.debug] mvar;
let r ← mkLambdaFVars #[y, x] mvar;
trace[Meta.debug] r;
let v := mkApp2 (mkConst `Nat.add) x y;
mvar.mvarId!.assign v;
trace[Meta.debug] mvar;
trace[Meta.debug] r;
let mctx ← getMCtx;
mctx.decls.forM fun mvarId mvarDecl => do
trace[Meta.debug] m!"?{mvarId.name} : {mvarDecl.type}"
}
set_option pp.mvars false
set_option trace.Meta.debug true
/--
info: [Meta.debug] ?_
[Meta.debug] fun y =>
let x := 0;
?_
[Meta.debug] x.add y
[Meta.debug] fun y =>
let x := 0;
x.add y
[Meta.debug] ?_uniq.3037 : Nat
[Meta.debug] ?_uniq.3038 : Nat → Nat → Nat
-/
#guard_msgs in
#eval tst1