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

Conjunctive polymorphic variants in class parameter constraints are rejected #4569

Closed
vicuna opened this issue Jun 25, 2008 · 1 comment
Closed
Labels

Comments

@vicuna
Copy link

vicuna commented Jun 25, 2008

Original bug ID: 4569
Reporter: @garrigue
Status: closed (set by @garrigue on 2008-06-25T03:06:31Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.10.2
Fixed in version: 3.10.3+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

Reported by Khoo Yit Phang on the caml list 2008-06-24:

I discovered that the attached snippet of Ocaml does not compile in
ocamlc, but does work in the ocaml toplevel (tested in v3.10.0 and
3.10.2). Removing anything (except the :int annotation) causes the
error to go away. Is it a bug in the type-checker?

cat polymorphic-variants-methods-bug.ml

class ['a] c (a : 'a) =
object (s)
method s = s
method d : int = match a with `A b -> b#num
end

ocamlc polymorphic-variants-methods-bug.ml

The implementation polymorphic-variants-methods-bug.ml
does not match the interface (inferred signature):
Type declarations do not match:
type 'a c = < d : int; s : 'a c >
constraint 'a = [< A of < num : int; .. > & < num : int; .. > ] is not included in type 'a c = < d : int; s : 'a c > constraint 'a = [< A of < num : int; .. > & < num : int; .. > & < num : int; ..

]

#ocamlc -i polymorphic-variants-methods-bug.ml
class ['a] c :
'a ->
object ('b)
constraint 'a = [< `A of < num : int; .. > ]
method d : int
method s : 'b
end

@vicuna
Copy link
Author

vicuna commented Jun 25, 2008

Comment author: @garrigue

This was due to the way unification is used during type expansion.
Fxied in branch release310 by making the unification rigid when
expanding a type during an equality check.

@vicuna vicuna closed this as completed Jun 25, 2008
@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