summaryrefslogtreecommitdiff
path: root/test-suite/modules/polymorphism.v
blob: 63eaa382dc05f8ba4aca95ee2f6ac61a573abb58 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
Set Universe Polymorphism.

(** Tests for module subtyping of polymorphic terms *)

Module Type S.

Section Foo.

Universes i j.
Constraint i <= j.

Parameter foo : Type@{i} -> Type@{j}.

End Foo.

End S.

(** Same constraints *)

Module OK_1.

Definition foo@{i j} (A : Type@{i}) : Type@{j} := A.

End OK_1.

Module OK_1_Test : S := OK_1.

(** More general constraints *)

Module OK_2.

Inductive X@{i} : Type@{i} :=.
Definition foo@{i j} (A : Type@{i}) : Type@{j} := X@{j}.

End OK_2.

Module OK_2_Test : S := OK_2.

(** Wrong instance length *)

Module KO_1.

Definition foo@{i} (A : Type@{i}) : Type@{i} := A.

End KO_1.

Fail Module KO_Test_1 : S := KO_1.

(** Less general constraints *)

Module KO_2.

Section Foo.

Universe i j.
Constraint i < j.

Definition foo (A : Type@{i}) : Type@{j} := A.

End Foo.

End KO_2.

Fail Module KO_Test_2 : S := KO_2.

(** Less general constraints *)

Module KO_3.

Section Foo.

Universe i j.
Constraint i = j.

Definition foo (A : Type@{i}) : Type@{j} := A.

End Foo.

End KO_3.

Fail Module KO_Test_3 : S := KO_3.