Debian Codegraph @

test-suite/success/primitive.v

raw
1 (* This file mostly tests for the error paths in declaring primitives.
2 Successes are tested in the various test-suite/primitive/* directories *)
3
4 (* [Primitive] should be forbidden in sections, otherwise its type
5 after cooking will be incorrect. *)
6 Section S.
7 Variable A : Type.
8 Fail Primitive int : let x := A in Set := #int63_type.
9 Fail Primitive int := #int63_type. (* we fail even if section variable not used *)
10 End S.
11 Section S.
12 Fail Primitive int := #int63_type. (* we fail even if no section variables *)
13 End S.
14
15 (* can't declare primitives with nonsense types *)
16 Fail Primitive xx : nat := #int63_type.
17
18 (* non-cumulative conversion *)
19 Fail Primitive xx : Type := #int63_type.
20
21 (* check evars *)
22 Fail Primitive xx : let x := _ in Set := #int63_type.
23
24 (* explicit type is unified with expected type, not just converted
25
26 extra universes are OK for monomorphic primitives (even though
27 their usefulness is questionable, there's no difference compared
28 with predeclaring them)
29 *)
30 Primitive xx : let x := Type in _ := #int63_type.
31
32 (* double declaration *)
33 Fail Primitive yy := #int63_type.
34
35 Module DoubleCarry.
36 (* XXX maybe should be an output test: this is the case where the new
37 declaration is already in the nametab so can be nicely printed *)
38 Module M.
39 Variant carry (A : Type) :=
40 | C0 : A -> carry A
41 | C1 : A -> carry A.
42
43 Register carry as kernel.ind_carry.
44 End M.
45
46 Module N.
47 Variant carry (A : Type) :=
48 | C0 : A -> carry A
49 | C1 : A -> carry A.
50
51 Fail Register carry as kernel.ind_carry.
52 End N.
53 End DoubleCarry.
54
55 (* univ polymorphic primitives *)
56
57 (* universe count must be as expected *)
58 Fail Primitive array@{u v} : Type@{u} -> Type@{v} := #array_type.
59
60 (* use a phantom universe to ensure we check conversion not just the universe count *)
61 Fail Primitive array@{u} : Set -> Set := #array_type.
62
63 (* no constraints allowed! *)
64 Fail Primitive array@{u | Set < u} : Type@{u} -> Type@{u} := #array_type.
65
66 (* unification works for polymorphic primitives too (although universe
67 counts mean it's not enough) *)
68 Fail Primitive array : let x := Type in _ -> Type := #array_type.
69 Primitive array : _ -> Type := #array_type.