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

Destructive type substitution drops constraint when argument is variant #7869

Closed
vicuna opened this Issue Nov 4, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@vicuna
Copy link
Collaborator

vicuna commented Nov 4, 2018

Original bug ID: 7869
Reporter: @paurkedal
Status: new
Resolution: open
Priority: normal
Severity: minor
Version: 4.07.1
Category: typing
Monitored by: @nojb @gasche

Bug description

The program

  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

fails with

  File "test.ml", line 5, characters 36-60:
  Error: Signature mismatch:
       Modules do not match:
         sig val f : 'a -> 'a end
       is not included in
         sig val f : [< `A ] -> [< `A ] end
       Values do not match:
         val f : 'a -> 'a
       is not included in
         val f : [< `A ] -> [< `A ]
       File "test.ml", line 3, characters 2-34: Expected declaration
       File "test.ml", line 6, characters 6-7: Actual declaration

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 < >.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 4, 2018

Comment author: @paurkedal

Correction: I should have filed this under "typing". (And maybe the severity should be higher.)

@vicuna vicuna added the typing label Mar 14, 2019

@trefis

This comment has been minimized.

Copy link
Contributor

trefis commented Mar 15, 2019

I could not reproduce on trunk or 4.08, here is the output of ocamlc -c -i on the example above:

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.
I'm closing, but I think it would be good to know what happened (I'm going to keep a note to have a look at this, but it might be a while before I do, so feel free to investigate!)

@trefis trefis closed this Mar 15, 2019

@paurkedal

This comment has been minimized.

Copy link

paurkedal commented Mar 16, 2019

Great! Seems this was fixed between 4.08+beta1 and 4.08+beta2.

@trefis

This comment has been minimized.

Copy link
Contributor

trefis commented Mar 18, 2019

Oh, indeed I hadn't noticed it was still broken on 4.08+beta1.
It appears it was fixed by #2261. I'm not going to dig into it any more than that.

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.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.