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
"Warning 62: Type constraints do not apply to GADT cases of variant types." Yes they do, you little liar :-) #7803
Comments
Comment author: @garrigue Indeed, the warning is here to avoid confusion over the scope of type variable in constraints.
|
Comment author: disteph Thanks for the answer. |
Comment author: @gasche I had a discussion with Stéphane (disteph) about this issue today, Variables in the constraint that are not type parameters are The intent of the warning is to warn users that, if an existential
One may think that the parameter of A is constrained to be This situation cannot occur in the original reported example, (I asked Stéphane whether he would be interested in trying to write On the other hand, I would personally find it more natural if the Finally, here is an answer to Stéphane's question of why we cannot
then it would be possible for other declarations in the module
which still allows to abstract over values of type Remark: we had fun playing with the following declaration of eq:
This is valid OCaml code, and it does what you expect: it's a version |
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
Since we all agree that currently the wording of the warning is wrong, I see 2 solutions:
|
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
Original bug ID: 7803
Reporter: disteph
Assigned to: @garrigue
Status: confirmed (set by @garrigue on 2018-06-11T04:12:38Z)
Resolution: open
Priority: normal
Severity: minor
Version: 4.06.1
Category: typing
Bug description
The code above triggers
Warning 62: Type constraints do not apply to GADT cases of variant types.
about the
constraint 'a = _*_
in the struct.However, if I remove
constraint 'a = _*_
in the struct, I get a real error message:Ideally, I would like to agree with the warning, and disagree with the error, expecting the type-checker to go through each constructor's type and verify that the output type does satisfy the constraint, which is the case in my example.
But if for some reason the type-checker cannot do that when it matches the inferred type from the signature's type, then at least I would like to help him with my constraint inside the struct and not get the warning.
The text was updated successfully, but these errors were encountered: