-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved error message for invalid private row type declaration #8732
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment here indicates that we know something about the user intent ("the syntax"), but the comment on the function declaration just says that "is_fixed_type" is a precondition. Maybe the comment on the function declaration could also, for people who are not expert on what "is_fixed_type" means, point out that we are working with a private type declaration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I would propose to update the name of the function to
set_private_row
too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not, but many places use
fixed
as an adjective, should they be updated too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A private row is a subcase of fixed rows, but
Typedecl
andset_fixed_row
only generate thisFixed_private
subcase.