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

type error involving 'include' and applicative functors #6786

Closed
vicuna opened this Issue Feb 17, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Feb 17, 2015

Original bug ID: 6786
Reporter: ceastlund
Assigned to: @lpw25
Status: resolved (set by @gasche on 2016-08-30T08:30:02Z)
Resolution: fixed
Priority: normal
Severity: minor
Target version: 4.03.1+dev
Fixed in version: 4.04.0 +dev / +beta1 / +beta2
Category: typing
Has duplicate: #6788
Monitored by: @lpw25 @yallop

Bug description

A specific pattern of using 'include' does not type check. It seems like the type checker can do better just by updating some module paths more aggressively.

The behavior I see is that Make_ok1 and Make_ok2 compile fine, but the very similar functor Make_bad does not. The code is in the box below; here is the compile error:

========================================

  Error: Signature mismatch:
         Modules do not match:
           sig
             module C : sig module T : sig  end type t = Make(T).t end
             module T = C.T
             type t = Make(T).t
           end
         is not included in
           sig type t module C : sig type t = t end end
         In module C:
         Modules do not match:
           sig module T : sig  end type t = Make(T).t end
         is not included in
           sig type t = C.t end
         In module C:
         Type declarations do not match:
           type t = Make(T).t
         is not included in
           type t = t

Steps to reproduce

module type S = sig type t end
module Make (M : sig end) : S = struct type t end

module Make_ok1 (M : sig end) : sig

type t
module A : S with type t = t

end = struct

module A = struct
include Make (struct end)
end
include A

end

module Make_ok2 (M : sig end) : sig

type t
module B : S with type t = t

end = struct

module T = struct end
module B = struct
include Make (T)
end
include B

end

module Make_bad (M : sig end) : sig

type t
module C : S with type t = t

end = struct

module C = struct
module T = struct end
include Make (T)
end
include C

end

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Aug 30, 2016

Comment author: @gasche

The example code above type-checks in my 4.04 branch with the following inferred signature:

module type S = sig type t end
module Make : functor (M : sig end) -> S
module Make_ok1 :
functor (M : sig end) -> sig type t module A : sig type t = t end end
module Make_ok2 :
functor (M : sig end) -> sig type t module B : sig type t = t end end
module Make_bad :
functor (M : sig end) -> sig type t module C : sig type t = t end end

Can this issue be closed or does the problem still occur in more complex scenarios?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Aug 30, 2016

Comment author: @lpw25

I think it can probably be closed. I'm pretty sure it is an instance of what

#708

fixes.

@vicuna vicuna closed this Aug 30, 2016

@vicuna vicuna added the typing label Mar 14, 2019

@vicuna vicuna added this to the 4.03.1 milestone Mar 14, 2019

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.