Skip to content
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

Module alias is not taken into account when checking module type compatibility (in a class type) #7036

Closed
vicuna opened this issue Nov 2, 2015 · 1 comment
Assignees

Comments

@vicuna
Copy link

@vicuna vicuna commented Nov 2, 2015

Original bug ID: 7036
Reporter: mandrykin
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2017-02-16T14:14:37Z)
Resolution: fixed
Priority: low
Severity: minor
Platform: x86_64
OS: Linux 3.19.0
OS Version: Ubuntu 15.04
Version: 4.02.3
Fixed in version: 4.03.0+dev / +beta1
Category: typing
Monitored by: @hcarty

Bug description

The following reduced example:

module M = struct
  module type S = sig type a val v : a end
  type 'a s = (module S with type a = 'a)
end

module B = struct
  class type a = object method a : 'a. 'a M.s -> 'a end
end

module M' = M
module B' = B

class b : B.a = object
  method a : 'a. 'a M.s -> 'a = fun (type a) ((module X) : (module M.S with type a = a)) -> X.v
end

class b' : B.a = object
  method a : 'a. 'a M'.s -> 'a = fun (type a) ((module X) : (module M'.S with type a = a)) -> X.v
end

is not accepted in both 4.02.3 and 4.03.0+trunk (4.03.0+dev11-2015-10-19):

Error: The class type object method a : 'a M'.s -> 'a end
       is not matched by the class type B.a
       The class type object method a : 'a M'.s -> 'a end
       is not matched by the class type object method a : 'a M.s -> 'a end
       The method a has type 'a. 'a M'.s -> 'a but is expected to have type
         'a. 'a M.s -> 'a
       Type 'a M'.s = (module M'.S with type a = 'a)
       is not compatible with type 'a0 M.s = (module M.S with type a = 'a0)

although as module M' is an alias for module M, module types M.S and M'.S actually refer to the same module type.

File attachments

@vicuna
Copy link
Author

@vicuna vicuna commented Nov 5, 2015

Comment author: @garrigue

Fixed in trunk in commit f32db11.

Structural equality on package types only work if the types do not contain free type variables (both Tvar and Tunivar). So we still need to expand the module path for aliases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants