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

Functor subtyping! #8209

Closed
vicuna opened this issue Jul 16, 2003 · 2 comments
Closed

Functor subtyping! #8209

vicuna opened this issue Jul 16, 2003 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jul 16, 2003

Original bug ID: 1757
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Jacek Chrzaszcz
Version: 3.06
OS: Linux
Submission from: dhcp17.labri.fr (147.210.9.112)

Hello,

By doing some experiments and looking at the type-checker's code I discovered
that
the subtyping of functor types is too restrictive!

In the papers of X.Leroy the rule is

E |- M_1' <: M_1 E,X:M_1' |- M_2 <: M_2'

E |- functor(X:M_1)M_2 <: functor(X:M_1')M_2'

while in the implementation, its right premise is

E,X:M_1 |- M_2 <: M_2'
^
no ' here

Consequently correct functor subtyping might be rejected. For example:

module type SUBTYPE = functor(X:sig type t end) -> sig type t=X.t end

module type SUPERTYPE = functor(X:sig type t type u=t end) -> sig type t=X.u
end

module S : SUBTYPE =
functor(X:sig type t end) -> struct type t=X.t end

module Tester(Y:SUPERTYPE) = struct end
module Test=Tester(S)

Is it a forgotten subtlety or is it on purpose, motivated by some subtle
compilation issues that I do not see?

Best regards to the Caml Team

Jacek

@vicuna
Copy link
Author

vicuna commented Jul 18, 2003

Comment author: administrator

Jacek,

By doing some experiments and looking at the type-checker's code I
discovered that the subtyping of functor types is too restrictive!
[...]
Is it a forgotten subtlety or is it on purpose, motivated by some subtle
compilation issues that I do not see?

You are correct. It's an oversight: there are no compilation issues
or otherwise that require the more restrictive rule currently
implemented. Actually, the bug has been there since the very
beginning (1995); it's a good thing that it only causes the
type-checker to err on the safe side.

I'll put the "real" functor subtyping rule for the next release.

Thanks for the feedback,

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Jul 18, 2003

Comment author: administrator

Fixed 2003-07-18 by XL

@vicuna vicuna closed this as completed Jul 18, 2003
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant