| 1 |
(* Test improved error messages for "with Definition" constraints *) |
| 2 |
|
| 3 |
(* Test 1: Type mismatch - expected nat but got bool *) |
| 4 |
Module Type T1. |
| 5 |
Parameter x : nat. |
| 6 |
End T1. |
| 7 |
Definition y1 : bool := true. |
| 8 |
Fail Module Type T1' := T1 with Definition x := y1. |
| 9 |
|
| 10 |
(* Test 2: Body mismatch - definitions with different values *) |
| 11 |
Module Type T2. |
| 12 |
Definition x := 0. |
| 13 |
End T2. |
| 14 |
Definition y2 : nat := 1. |
| 15 |
Fail Module Type T2' := T2 with Definition x := y2. |
| 16 |
|
| 17 |
(* Test 3: Polymorphic constraint mismatch *) |
| 18 |
Module Type T3. |
| 19 |
Polymorphic Parameter p : Type. |
| 20 |
End T3. |
| 21 |
Fail Module Type T3' := T3 with Definition p := nat. |
| 22 |
|
| 23 |
(* Test 4: Universe constraint issues *) |
| 24 |
Module Type T4. |
| 25 |
Parameter x : Set. |
| 26 |
End T4. |
| 27 |
Definition y4 := Type. |
| 28 |
Fail Module Type T4' := T4 with Definition x := y4. |
| 29 |
|
| 30 |
(* NOTE: WithCannotConstrainPrimitive and WithCannotConstrainSymbol errors |
| 31 |
cannot be triggered from user code because module types export primitives |
| 32 |
and symbols as parameters. These errors exist for internal consistency. *) |