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

Unused variance specification allowed on destructive type substitution #6672

Closed
vicuna opened this Issue Nov 24, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Nov 24, 2014

Original bug ID: 6672
Reporter: @lpw25
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2016-12-07T10:47:37Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.03.0+dev / +beta1
Target version: 4.02.3+dev
Fixed in version: 4.03.0+dev / +beta1
Category: ~DO NOT USE (was: OCaml general)

Bug description

Destructive type substitutions can give a variance specification to their parameters, but it is completely ignored and not even checked for correctness:

# module type S = sig type 'a t val x : int t end;;
module type S = sig type 'a t val x : int t end

# module type T = S with type +'a t := 'a list;;
module type T = sig val x : int list end

# module type T = S with type -'a t := 'a list;;
module type T = sig val x : int list end
@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 24, 2014

Comment author: @lpw25

It seems the same is true for non-destructive type substitution:

# module type S = sig type 'a t end;;
module type S = sig type 'a t end

# module type T = S with type +'a t = 'a list;;
module type T = sig type 'a t = 'a list end

# module type T = S with type -'a t = 'a list;;
module type T = sig type 'a t = 'a list end

I suggest that the variance annotations are either checked (by setting the check parameter of compute_variance_decl to true in transl_with_constraint) or banned by the parser.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Apr 20, 2015

Comment author: @garrigue

Fixed in trunk at revision 16024.
Now the specification is checked.
Only commit this in trunk, as this could in theory break some working programs.

@vicuna vicuna closed this Dec 7, 2016

@vicuna vicuna added this to the 4.02.3 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.