lean4-htt/tests/lean/run/issue8107.lean
Joachim Breitner bca36b2eba
refactor: realizeConst: do not set declPrefix (#8107)
This PR makes `realizeConst` to not set a `declPrefix`. This allows the
realization of both `foo.eq_def` and `bar.eq_def`, where `foo` and `bar`
are mutually recursive, all attached to the same function's environment.
2025-04-28 13:43:52 +00:00

35 lines
1,006 B
Text

import Lean.Meta
/-!
This test checks that within ```realizeConst ``foo `foo.test``` we are not restricted
to adding declarations with a name scoped under `foo`, but can add any names
to the environment. This is important for constructions that add names to each
function in a mutual recursive group.
-/
def foo := True
def bar := True
open Lean Meta
-- NOTE: declaring and running a `realizeConst` invocation isn't usually done in the same file, so
-- changing the closure below may require a server restart to see the changes.
run_meta do
realizeConst ``foo `foo.test do
addDecl <| Declaration.thmDecl {
name := `foo.test
type := mkConst ``True
value := mkConst ``True.intro
levelParams := [] }
addDecl <| Declaration.thmDecl {
name := `bar.test
type := mkConst ``True
value := mkConst ``True.intro
levelParams := [] }
/-- info: foo.test : True -/
#guard_msgs in
#check foo.test
/-- info: bar.test : True -/
#guard_msgs in
#check bar.test