-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8732 from Octachron/remove_fixed_type_error_2
Improved error message for invalid private row type declaration
- Loading branch information
Showing
5 changed files
with
93 additions
and
20 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
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,52 @@ | ||
(* TEST | ||
* expect | ||
*) | ||
|
||
(** Error message for trying to make private a row type variable | ||
that only exists syntactically *) | ||
|
||
type a = [`A | `C | `D] | ||
type b = [`B | `D | `E] | ||
type c = private [< a | b > `A `B `C `D `E] | ||
[%%expect {| | ||
type a = [ `A | `C | `D ] | ||
type b = [ `B | `D | `E ] | ||
Line 6, characters 0-43: | ||
6 | type c = private [< a | b > `A `B `C `D `E] | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
Error: This private row type declaration is invalid. | ||
The type expression on the right-hand side reduces to | ||
[ `A | `B | `C | `D | `E ] | ||
which does not have a free row type variable. | ||
Hint: If you intended to define a private type abbreviation, | ||
write explicitly | ||
private [ `A | `B | `C | `D | `E ] | ||
|}] | ||
|
||
type u = private < x:int; .. > as 'a constraint 'a = < x: int > ;; | ||
[%%expect {| | ||
Line 1, characters 0-63: | ||
1 | type u = private < x:int; .. > as 'a constraint 'a = < x: int > ;; | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
Error: This private row type declaration is invalid. | ||
The type expression on the right-hand side reduces to | ||
< x : int > | ||
which does not have a free row type variable. | ||
Hint: If you intended to define a private type abbreviation, | ||
write explicitly | ||
private < x : int > | ||
|}] | ||
|
||
type u = private [> `A ] as 'a constraint 'a = [< `A ] ;; | ||
[%%expect {| | ||
Line 1, characters 0-54: | ||
1 | type u = private [> `A ] as 'a constraint 'a = [< `A ] ;; | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
Error: This private row type declaration is invalid. | ||
The type expression on the right-hand side reduces to | ||
[ `A ] | ||
which does not have a free row type variable. | ||
Hint: If you intended to define a private type abbreviation, | ||
write explicitly | ||
private [ `A ] | ||
|}] |
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
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