Debian Codegraph @

test-suite/ltac2/deprecation.v

raw
1 Require Import Ltac2.Ltac2.
2
3 Set Warnings "+deprecated".
4
5 Ltac2 Type foo := [
6 | #[deprecated(since="bar")] Bar
7 | #[deprecated(since="baz")] Baz
8 ].
9
10 (* can still use foo even if its constructors are deprecated *)
11 Ltac2 diagonal (x:foo) := (x, x).
12
13 (* deprecated constructors warn when using them to construct values *)
14 Fail Ltac2 nobuild := Bar.
15
16 (* deprecated constructors also warn when matching on them *)
17 Fail Ltac2 nomatch x :=
18 match x with
19 | Bar => 0
20 | _ => 1
21 end.
22
23 (* warnings are per constructor so we can disable one and not the other
24 (because this test uses difference "since" annotations) *)
25 Set Warnings "-deprecated-since-bar".
26
27 Fail Ltac2 nobuild := Baz.
28
29 Ltac2 build_warn_bar_disabled := Bar.
30
31 (* warnings are per constructor, so we still can't match on Baz *)
32 Fail Ltac2 nomatch x :=
33 match x with
34 | Baz => 0
35 | _ => 1
36 end.
37
38 (* but we can match on Bar with its warning disabled *)
39 Ltac2 match_warn_bar_disabled x :=
40 match x with
41 | Bar => 0
42 | _ => 1
43 end.
44
45 (* the warning is at intern time *)
46 Ltac2 Abbreviation bar_nota := Bar.
47
48 Ltac2 Notation "isBar_nota" x(tactic) := match x with Bar => true | _ => false end.
49
50 Set Warnings "+deprecated-since-bar".
51
52 (* sanity check *)
53 Fail Ltac2 nobuild := Bar.
54
55 Ltac2 bar_def := bar_nota.
56
57 Ltac2 isBar_def x := isBar_nota x.
58
59 Ltac2 Eval Control.assert_true (isBar_def bar_def).
60
61 #[warnings="-deprecated-since-baz"]
62 Ltac2 Eval Control.assert_false (isBar_def Baz).