lean4-htt/tests/lean/run/issue10821.lean
Joachim Breitner 74fd46894f
fix: deprecation warning location with field notation (#10826)
This PR fixes the location of the “deprecated constant” and similar
error messages on field notation (`e.f`, `(e).f`, `e |>. f`). Fixes
#10821.
2025-10-23 20:55:25 +00:00

65 lines
1.2 KiB
Text

set_option linter.deprecated true
/-!
Checks that deprecated names in projection notation cause just
the name to be marked, not the whole expression.
-/
def Nat.inc (n : Nat) : Nat := n + 1
@[deprecated inc (since := "2025-10-17")]
def Nat.inc' (n : Nat) : Nat := n + 1
/--
@ +3:5...9
warning: `Nat.inc'` has been deprecated: Use `Nat.inc` instead
-/
#guard_msgs (positions := true) in
example (n : Nat) : Nat :=
n
|>.inc'
/--
@ +2:7...11
warning: `Nat.inc'` has been deprecated: Use `Nat.inc` instead
-/
#guard_msgs (positions := true) in
example (n : Nat) : Nat :=
n |>.inc'
/--
@ +2:6...10
warning: `Nat.inc'` has been deprecated: Use `Nat.inc` instead
-/
#guard_msgs (positions := true) in
example (n : Nat) : Nat :=
(n).inc'
/--
@ +2:4...8
warning: `Nat.inc'` has been deprecated: Use `Nat.inc` instead
-/
#guard_msgs (positions := true) in
example (n : Nat) : Nat :=
n.inc'
/--
@ +2:4...8
error: Invalid field `incc`: The environment does not contain `Nat.incc`
n
has type
Nat
-/
#guard_msgs (positions := true) in
example (n : Nat) : Nat :=
n.incc
/--
@ +2:4...8
error: Invalid field `incc`: The environment does not contain `Nat.incc`
n
has type
Nat
-/
#guard_msgs (positions := true) in
example (n : Nat) : Nat :=
n.incc.foo