Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
"Warning 62: Type constraints do not apply to GADT cases of variant types." Yes they do, you little liar :-) #7803
Original bug ID: 7803
module Test : sig
The code above triggers "Warning 62: Type constraints do not apply to GADT cases of variant types."
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.
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
type 'a t = A : 'b -> (int * int) t
One may think that the parameter of A is constrained to be "int",
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
Remark: we had fun playing with the following declaration of eq:
type ('a, 'b) eq = Refl : ('c, 'c) eq
This is valid OCaml code, and it does what you expect: it's a version