At position module Make(Analysis) : <here> Values do not match:
val of_var : string -> [ `Location of t | `None | `Value of t ]
is not included in
val of_var : string -> [ `Location of t | `None | `Value of t ]
(no observable difference in types and no visible type variables) (in 4.05.0)
However, if either generalization is requested for the value `of_var' using eta-expansion or a type annotation that does not involve the type maybe_region is added, the error disappears. So either of the following works:
moduleMake (Analysis : Analysis) =structincludeAnalysisletof_varx= of_var ~f:"" x
end
The types like [`A of _ | `B of _ | `C] t where 'a t = 'a constraint 'a = [`A of t1 | `B of t2 | `C of t3 | `D of ... | .... | `X of tn] are convenient for avoiding repeating the types of the polymorphic constructors if they are taken from some pre-defined set e.g. using [`Location of _ | `None] maybe_region instead of [`Location of U.t * [`None | `Value of U.t] | `None].
Interesting. This bug is related to the change in 4.04, where locally defined abstract types cannot be used to instantiate non-generalizable type variables once the defining module is left.
First remark: there is an easy workaround, adding a variance annotation:
type +'a maybe_region = ...
I'm thinking of a fix that wouldn't break principality for this case.
Original bug ID: 7601
Reporter: mandrykin
Assigned to: @garrigue
Status: resolved (set by @garrigue on 2017-09-12T23:35:43Z)
Resolution: fixed
Priority: low
Severity: minor
Platform: x86_64
OS: Linux 4.4.0
OS Version: Ubuntu 16.04.2
Version: 4.05.0
Fixed in version: 4.06.0 +dev/beta1/beta2/rc1
Category: typing
Bug description
The following fragment:
produces the following inclusion error:
(no observable difference in types and no visible type variables) (in 4.05.0)
However, if either generalization is requested for the value `of_var' using eta-expansion or a type annotation that does not involve the type maybe_region is added, the error disappears. So either of the following works:
or
but not
Additional information
The types like
[`A of _ | `B of _ | `C] t where 'a t = 'a constraint 'a = [`A of t1 | `B of t2 | `C of t3 | `D of ... | .... | `X of tn]
are convenient for avoiding repeating the types of the polymorphic constructors if they are taken from some pre-defined set e.g. using[`Location of _ | `None] maybe_region
instead of[`Location of U.t * [`None | `Value of U.t] | `None]
.File attachments
The text was updated successfully, but these errors were encountered: