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

variance not inferred for package type #5337

Closed
vicuna opened this issue Aug 15, 2011 · 8 comments
Closed

variance not inferred for package type #5337

vicuna opened this issue Aug 15, 2011 · 8 comments
Assignees
Labels
feature-wish known-limitation Acknowledge the problem, but there is no plan to fix it Stale typing

Comments

@vicuna
Copy link

vicuna commented Aug 15, 2011

Original bug ID: 5337
Reporter: sweeks
Assigned to: @garrigue
Status: assigned (set by @mshinwell on 2016-12-07T15:38:04Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.12.0
Category: typing
Related to: #7151
Monitored by: @yallop yminsky

Bug description

OCaml doesn't accept the following program, because it does not infer that type t is
covariant.

  module type S = sig
    type t
    val x : t
  end
  
  type +'a t = (module S with type t = 'a)

It would be nice if OCaml's variance inference would look inside package types.

@vicuna
Copy link
Author

vicuna commented Aug 15, 2011

Comment author: yminsky

Note that this also fails in 3.12.1

# module type S = sig type t val x : t end;;
module type S = sig type t val x : t end
# type +'a t = (module S with type t = 'a);;
Error: In this definition, expected parameter variances are not satisfied.
The 1st type parameter was expected to be covariant,
but it is invariant

@vicuna
Copy link
Author

vicuna commented Dec 10, 2011

Comment author: @garrigue

Unfortunately, there is no cheap solution.
Computing the variance of a module would require going through all syntactic constructs, which probably means a huge number of lines of code.
An easy workaround is to use objects in place of first-class modules, at least when you need variance :-)

@vicuna
Copy link
Author

vicuna commented Dec 7, 2016

Comment author: @mshinwell

Jacques: is this ever going to be fixed?

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @garrigue

A fix would require a breakthrough in our understanding of the interaction between modules and variance.
So I see no general fix anytime soon.

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @mshinwell

For things like this I wonder if we should have a "known list of limitations" to which these items can be added, rather than keeping Mantis issues open for many years. Is there anything like that (or could we start something like that?) for the type checker?

@github-actions
Copy link

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label May 15, 2020
@garrigue
Copy link
Contributor

@mshinwell suggested a solution to this entry, in the form of a list of known limitations.
I see a number of potential entries. Where should it go?

@github-actions github-actions bot removed the Stale label Jun 24, 2020
@damiendoligez damiendoligez added the known-limitation Acknowledge the problem, but there is no plan to fix it label Oct 15, 2020
@github-actions
Copy link

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-wish known-limitation Acknowledge the problem, but there is no plan to fix it Stale typing
Projects
None yet
Development

No branches or pull requests

3 participants