lean4-htt/tests/lean/run/2220.lean
Kyle Miller 29303b37b8
feat: have raw nat lits pretty print with nat_lit when pp.explicit is set (#7805)
This PR modifies the pretty printing of raw natural number literals; now
both `pp.explicit` and `pp.natLit` enable the `nat_lit` prefix. An
effect of this is that the hover on such a literal in the Infoview has
the `nat_lit` prefix.

Amendment to RFC #3021: In the reference-level explanation, now it
should read

> When `pp.natLit` and `pp.explicit` are false, then the `nat_lit n`
expression delaborates as `n`, and otherwise it delaborates as `nat_lit
n`.
2025-04-03 20:38:09 +00:00

38 lines
1.2 KiB
Text

/-! Coercions should ignore the RHS of `^` -/
set_option pp.coercions false
set_option pp.explicit true
/--
info: @HPow.hPow Int Nat Int (@instHPow Int Nat (@instPowNat Int Int.instNatPow))
(@OfNat.ofNat Int (nat_lit 3) (@instOfNat (nat_lit 3)))
(@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) : Int
-/
#guard_msgs in
#check (3 : Int) ^ 2
-- 3 is Int
-- 2 is Nat
/--
info: @HAdd.hAdd Int Int Int (@instHAdd Int Int.instAdd) (@OfNat.ofNat Int (nat_lit 1) (@instOfNat (nat_lit 1)))
(@HPow.hPow Int Nat Int (@instHPow Int Nat (@instPowNat Int Int.instNatPow))
(@OfNat.ofNat Int (nat_lit 3) (@instOfNat (nat_lit 3)))
(@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) : Int
-/
#guard_msgs in
#check (1 : Int) + 3 ^ 2
-- 1 is Int
-- 3 is Int
-- 2 is Nat
/--
info: @HAdd.hAdd Int Int Int (@instHAdd Int Int.instAdd) (@OfNat.ofNat Int (nat_lit 1) (@instOfNat (nat_lit 1)))
(@HPow.hPow Int Nat Int (@instHPow Int Nat (@instPowNat Int Int.instNatPow))
(@OfNat.ofNat Int (nat_lit 3) (@instOfNat (nat_lit 3)))
(@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) : Int
-/
#guard_msgs in
#check (1 + 3 ^ 2 : Int)
-- 1 is Int
-- 3 is Int
-- 2 is Nat