forked from lpw25/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new test cases for module inclusion errors
These test cases will have improved error messages in the next commit
- Loading branch information
Showing
4 changed files
with
521 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
(* TEST | ||
* expect | ||
*) | ||
|
||
module M : sig | ||
val x : bool * int | ||
end = struct | ||
let x = false , "not an int" | ||
end | ||
[%%expect{| | ||
Lines 3-5, characters 6-3: | ||
3 | ......struct | ||
4 | let x = false , "not an int" | ||
5 | end | ||
Error: Signature mismatch: | ||
Modules do not match: | ||
sig val x : bool * string end | ||
is not included in | ||
sig val x : bool * int end | ||
Values do not match: | ||
val x : bool * string | ||
is not included in | ||
val x : bool * int | ||
|}] | ||
|
||
module T : sig | ||
val f : int -> (float * string ref) list | ||
end = struct | ||
let f x = x + List.length [0.0, ref true] | ||
end | ||
[%%expect{| | ||
Lines 3-5, characters 6-3: | ||
3 | ......struct | ||
4 | let f x = x + List.length [0.0, ref true] | ||
5 | end | ||
Error: Signature mismatch: | ||
Modules do not match: | ||
sig val f : int -> int end | ||
is not included in | ||
sig val f : int -> (float * string ref) list end | ||
Values do not match: | ||
val f : int -> int | ||
is not included in | ||
val f : int -> (float * string ref) list | ||
|}] | ||
|
||
(* Alpha-equivalence *) | ||
module T : sig | ||
val f : ('a list * 'b list -> int) | ||
end = struct | ||
let f : ('c list * 'd ref -> int) = assert false | ||
end | ||
[%%expect{| | ||
Lines 3-5, characters 6-3: | ||
3 | ......struct | ||
4 | let f : ('c list * 'd ref -> int) = assert false | ||
5 | end | ||
Error: Signature mismatch: | ||
Modules do not match: | ||
sig val f : 'c list * 'd ref -> int end | ||
is not included in | ||
sig val f : 'a list * 'b list -> int end | ||
Values do not match: | ||
val f : 'c list * 'd ref -> int | ||
is not included in | ||
val f : 'a list * 'b list -> int | ||
|}] | ||
|
||
module T : sig | ||
type t = int * float | ||
end = struct | ||
type t = bool * float | ||
end | ||
[%%expect{| | ||
Lines 3-5, characters 6-3: | ||
3 | ......struct | ||
4 | type t = bool * float | ||
5 | end | ||
Error: Signature mismatch: | ||
Modules do not match: | ||
sig type t = bool * float end | ||
is not included in | ||
sig type t = int * float end | ||
Type declarations do not match: | ||
type t = bool * float | ||
is not included in | ||
type t = int * float | ||
|}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
(* TEST | ||
* expect | ||
*) | ||
|
||
(* From jctis: <https://github.com/ocaml/ocaml/issues/10399> *) | ||
|
||
module PR10399 : sig | ||
type t = < x : int > | ||
|
||
class c : object method x : int method y : bool end | ||
|
||
val o : t | ||
end = struct | ||
type t = < x : int > | ||
|
||
class c = object method x = 3 method y = true end | ||
|
||
let o = new c | ||
end | ||
|
||
[%%expect{| | ||
Lines 7-13, characters 6-3: | ||
7 | ......struct | ||
8 | type t = < x : int > | ||
9 | | ||
10 | class c = object method x = 3 method y = true end | ||
11 | | ||
12 | let o = new c | ||
13 | end | ||
Error: Signature mismatch: | ||
Modules do not match: | ||
sig | ||
type t = < x : int > | ||
class c : object method x : int method y : bool end | ||
val o : c | ||
end | ||
is not included in | ||
sig | ||
type t = < x : int > | ||
class c : object method x : int method y : bool end | ||
val o : t | ||
end | ||
Values do not match: val o : c is not included in val o : t | ||
|}] |
Oops, something went wrong.