aboutsummaryrefslogtreecommitdiff
path: root/test-suite/ltac2/rebind.v
blob: 6cec49de1efa1ac5e43af5521d6ed97cea736cc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Require Import Ltac2.Ltac2 Ltac2.Notations.

Ltac2 mutable foo () := constructor.

Goal True.
Proof.
foo ().
Qed.

Ltac2 Set foo := fun _ => fail.

Goal True.
Proof.
Fail foo ().
constructor.
Qed.

(** Not the right type *)
Fail Ltac2 Set foo := 0.

Ltac2 bar () := ().

(** Cannot redefine non-mutable tactics *)
Fail Ltac2 Set bar := fun _ => ().

(** Subtype check *)

Ltac2 mutable rec f x := f x.

Fail Ltac2 Set f := fun x => x.

Ltac2 mutable g x := x.

Ltac2 Set g := f.

(* Rebinding with old values *)

Ltac2 mutable qux () := Message.print (Message.of_string "Hello").

Ltac2 Set qux as self := fun () => self (); self ().

Ltac2 Eval qux ().

Ltac2 Type rec nat := [O | S (nat)].

Ltac2 mutable quz := O.

Ltac2 Set quz as self := S self.

Ltac2 Eval quz.