Debian Codegraph @

test-suite/output/ModuleErrors.v

raw
1 (* Test improved error messages for module type errors *)
2
3 (* Test 1: NotConvertibleInductiveField - types given to inductive differ *)
4 Module Type IndType1.
5 Inductive I : Type := c : nat -> I.
6 End IndType1.
7 Module IndMod1.
8 Inductive I : Type := c : bool -> I.
9 End IndMod1.
10 Fail Module IndTest1 : IndType1 := IndMod1.
11
12 (* Test 2: NotConvertibleConstructorField - constructor types differ *)
13 Module Type ConsType1.
14 Inductive I : Type := c1 : nat -> I | c2 : I.
15 End ConsType1.
16 Module ConsMod1.
17 Inductive I : Type := c1 : bool -> I | c2 : I.
18 End ConsMod1.
19 Fail Module ConsTest1 : ConsType1 := ConsMod1.
20
21 (* Test 3: NotSameConstructorNamesField - constructor names differ *)
22 Module Type ConsNameType.
23 Inductive I : Type := foo : I | bar : I.
24 End ConsNameType.
25 Module ConsNameMod.
26 Inductive I : Type := baz : I | qux : I.
27 End ConsNameMod.
28 Fail Module ConsNameTest : ConsNameType := ConsNameMod.
29
30 (* Test 4: NotSameInductiveNameInBlockField - mutual inductive type names differ *)
31 Module Type IndNameType.
32 Inductive Foo : Type := mkFoo : Bar -> Foo
33 with Bar : Type := mkBar : Foo -> Bar.
34 End IndNameType.
35 Module IndNameMod.
36 Inductive Foo : Type := mkFoo : Baz -> Foo
37 with Baz : Type := mkBar : Foo -> Baz.
38 End IndNameMod.
39 Fail Module IndNameTest : IndNameType := IndNameMod.
40
41 (* Test 5: InductiveNumbersFieldExpected - number of inductives differs *)
42 Module Type NumIndType.
43 Inductive I1 : Type := c1 : I1
44 with I2 : Type := c2 : I2.
45 End NumIndType.
46 Module NumIndMod.
47 Inductive I1 : Type := c1 : I1.
48 End NumIndMod.
49 Fail Module NumIndTest : NumIndType := NumIndMod.
50
51 (* Test 6: InductiveParamsNumberField - number of parameters differs *)
52 Module Type ParamsType.
53 Inductive I (A B : Type) : Type := c : A -> B -> I A B.
54 End ParamsType.
55 Module ParamsMod.
56 Inductive I (A : Type) : Type := c : A -> A -> I A.
57 End ParamsMod.
58 Fail Module ParamsTest : ParamsType := ParamsMod.
59
60 (* Test 7: NotConvertibleBodyField - body of definitions differs *)
61 Module Type BodyType.
62 Definition x := 42.
63 End BodyType.
64 Module BodyMod.
65 Definition x := 0.
66 End BodyMod.
67 Fail Module BodyTest : BodyType := BodyMod.
68
69 (* Test 8: NotConvertibleTypeField - type of definitions differs *)
70 Module Type TypeFieldType.
71 Definition x : nat := 0.
72 End TypeFieldType.
73 Module TypeFieldMod.
74 Definition x : bool := true.
75 End TypeFieldMod.
76 Fail Module TypeFieldTest : TypeFieldType := TypeFieldMod.
77
78 (* Test 9: With Definition type mismatch with complex types from module *)
79 Module Type WithParamType.
80 Parameter a : Type.
81 Parameter b : a.
82 End WithParamType.
83 Fail Module Type WithParamTest := WithParamType with Definition a := nat with Definition b := true.
84
85 (* Test 10: Nested with definition error - type mismatch in submodule *)
86 Module Type InnerType.
87 Parameter x : nat.
88 End InnerType.
89 Module Type NestedWithType.
90 Declare Module Inner : InnerType.
91 End NestedWithType.
92 Fail Module Type NestedWithTest := NestedWithType with Definition Inner.x := true.
93
94 (* Test 11: RecordFieldExpected - expected record but got non-record *)
95 Module Type RecType.
96 Record R := { field : nat }.
97 End RecType.
98 Module RecMod.
99 Inductive R := mkR : nat -> R.
100 End RecMod.
101 Fail Module RecTest : RecType := RecMod.
102
103 (* Test 12: RecordProjectionsExpected - projection names differ *)
104 Module Type RecProjType.
105 Record R := { foo : nat; bar : bool }.
106 End RecProjType.
107 Module RecProjMod.
108 Record R := { baz : nat; qux : bool }.
109 End RecProjMod.
110 Fail Module RecProjTest : RecProjType := RecProjMod.
111
112 (* Test 13: FiniteInductiveFieldExpected - inductive vs coinductive *)
113 Module Type FiniteType.
114 Inductive I := c : I.
115 End FiniteType.
116 Module FiniteMod.
117 CoInductive I := c : I.
118 End FiniteMod.
119 Fail Module FiniteTest : FiniteType := FiniteMod.
120
121 (* Test 14: With Definition body mismatch *)
122 Module Type WithBodyType.
123 Definition x := 5.
124 End WithBodyType.
125 Fail Module Type WithBodyTest := WithBodyType with Definition x := 10.