lean4-htt/tests/elab/issue5562.lean
Garmelon 08eb78a5b2
chore: switch to new test/bench suite (#12590)
This PR sets up the new integrated test/bench suite. It then migrates
all benchmarks and some related tests to the new suite. There's also
some documentation and some linting.

For now, a lot of the old tests are left alone so this PR doesn't become
even larger than it already is. Eventually, all tests should be migrated
to the new suite though so there isn't a confusing mix of two systems.
2026-02-25 13:51:53 +00:00

66 lines
1.2 KiB
Text

import Lean
/-!
This test checks that we can enter, typecheck etc. terms that are only type-correct at
transparency `all`.
-/
open Lean Meta
def T := Nat → Nat
def x : T := fun n => n + 1
-- All well:
def n1 : Nat := x 1
-- Now we make `T` irreducible. A bunch of things should break:
attribute [irreducible] T
/--
error: Function expected at
x
but this term has type
T
Note: Expected a function because this term is being applied to the argument
1
-/
#guard_msgs in
def n2 : Nat := x 1
-- NB: Checking does not break! Always done at transparency `all`.
run_meta do
Meta.check (.app (mkConst ``x) (mkNatLit 1))
-- Type inference fails:
/--
error: function expected
x 1
-/
#guard_msgs in
run_meta do
let _ ← Meta.inferType (.app (mkConst ``x) (mkNatLit 1))
-- But succeeds at transparency .all
run_meta do
withTransparency .all do
let _ ← Meta.inferType (.app (mkConst ``x) (mkNatLit 1))
-- An elaborator that sets transparency to .all:
elab "with_unfolding_all" t:term : term <= expectedType? =>
withTransparency .all <|
Elab.Term.elabTerm t expectedType?
/--
error: function expected
x 1
-/
#guard_msgs in
def n3 : Nat := with_unfolding_all x 1