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 equality broken for conjunctive polymorphic variant tags #5927

Closed
vicuna opened this issue Feb 19, 2013 · 4 comments
Closed

Type equality broken for conjunctive polymorphic variant tags #5927

vicuna opened this issue Feb 19, 2013 · 4 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented Feb 19, 2013

Original bug ID: 5927
Reporter: @lpw25
Assigned to: @garrigue
Status: resolved (set by @garrigue on 2017-03-14T10:20:51Z)
Resolution: fixed
Priority: normal
Severity: minor
Target version: undecided
Fixed in version: 4.06.0 +dev/beta1/beta2/rc1
Category: typing
Tags: patch
Monitored by: @lpw25

Bug description

I think that the following behaviour is a bug:

type 'a foo = 'a constraint 'a = [< `Tag of & int];;

Error: Type declarations do not match:
type 'a foo = 'a constraint 'a = [< Tag of & int ] is not included in type 'a foo = 'a constraint 'a = [< Tag of & int ]

I've attached a patch that seems to fix it.

File attachments

@vicuna
Copy link
Author

vicuna commented Feb 19, 2013

Comment author: @lpw25

I've attached a new fix that is probably more consistent with other behaviour.

@vicuna
Copy link
Author

vicuna commented Feb 20, 2013

Comment author: @garrigue

Actually, the failure in this case is intentional, as this conjunction is clearly impossible.
On the other hand, it could be accepted in a more general way: & t1 is probably equivalent to & t2 for any t1 and t2...
(Oops, there is also the problem of free variables)

@vicuna
Copy link
Author

vicuna commented Feb 20, 2013

Comment author: @lpw25

Even if the conjunction is impossible, the type itself is valid and should at least be considered equivalent to itself.

Also, the current error is unclear and only occurs during module inclusion checks. For example:

module type S = sig type 'a foo constraint 'a = [< `Tag of & int ] end;;

Error: Module type declarations do not match:
module type S =
sig type 'a foo constraint 'a = [< Tag of & int ] end does not match module type S = sig type 'a foo constraint 'a = [< Tag of & int ] end
At position module type S =
Modules do not match:
sig type 'a foo constraint 'a = [< Tag of & int ] end is not included in sig type 'a foo constraint 'a = [< Tag of & int ] end
At position module type S =
Type declarations do not match:
type 'a foo constraint 'a = [< Tag of & int ] is not included in type 'a foo constraint 'a = [< Tag of & int ]
Their constraints differ.

@vicuna
Copy link
Author

vicuna commented Mar 14, 2017

Comment author: @garrigue

Fixed by commit c21ffce, in a slightly more general way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants