Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Destructive type substitution drops constraint when argument is variant #7869
module type S = sig type +'a t val f : ([< `A] as 'a) t -> 'a t end module M : S with type 'a t := 'a = struct let f x = x end
for OCaml 4.06.1, 4.07.1, and current master (fd5c692). As seen, the constraint between the argument and result type of f is lost. This does not happen if the argument is not constrained to a polymorphic variant, including when constrained to and object type like < >.
I could not reproduce on trunk or 4.08, here is the output of
module type S = sig type +'a t val f : ([< `A ] as 'a) t -> 'a t end module M : sig val f : ([< `A ] as 'a) -> 'a end
I don't know what would have changed this, nor do I have the time to look into it right now.