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

First class polymorphism losing with separate compilation #3653

Closed
vicuna opened this issue Sep 10, 2002 · 1 comment
Closed

First class polymorphism losing with separate compilation #3653

vicuna opened this issue Sep 10, 2002 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Sep 10, 2002

Original bug ID: 1382
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Related to: #3652
Parent of: #3655

Bug description

Hmm, this email bounced the first time. Try #2.

Here's 60 lines of source code that breaks the current ocamlc from
CVS. Sorry I can't make it smaller.

It may be significant that the error message ends up mentioning

< format_eventid_tag : 'a. ([> `ANY] as 'b) Conscious.CD.eventid -> unit >

when in the actual code, the type variable argument to
format_eventid_tag is always equal to the type variable in the first
argument. That is, the 'a and 'b should not be different in the
above.

When I have shuffled text so it is less than 3 files, the problem
went away. To reproduce the problem, give these commands:

ocamlc -c conscious_data.ml
ocamlc -c conscious.ml
ocamlc -c ouch.ml

and you'll get this compiler error:

File "ouch.ml", line 9, characters 22-155:
Signature mismatch:
Modules do not match:
sig
class ['a] structure_read_desc :
object
constraint 'a = [> ANY] method dump : Conscious.CD.formatter -> string array -> unit end end is not included in Event Class declarations do not match: class ['a] structure_read_desc : object constraint 'a = [> ANY]
method dump : Conscious.CD.formatter -> string array -> unit
end
does not match
class ['a] structure_read_desc :
object
constraint 'a = [> ANY] method dump : CD.formatter -> string array -> unit end The class type object method dump : Conscious.CD.formatter -> string array -> unit end is not matched by the class type object method dump : CD.formatter -> string array -> unit end The method dump has type Conscious.CD.formatter -> string array -> unit but is expected to have type CD.formatter -> string array -> unit Type Conscious.CD.formatter = < format_eventid_tag : 'a. ([> ANY] as 'b) Conscious.CD.eventid -> unit >
is not compatible with type
CD.formatter =
< format_eventid_tag : 'c. ([> `ANY] as 'c) CD.eventid -> unit >
Type 'b Conscious.CD.eventid = 'b Conscious_data.Conscious_data.eventid
is not compatible with type
'c CD.eventid = 'c Conscious_data.Conscious_data.eventid

ouch.ml contains:

module CD = Conscious_data.Conscious_data
module C = Conscious.Conscious

module type Event = sig
class ['a] structure_read_desc: [[>`ANY] as 'a] CD.eventdesc
end

(* The : Event is essential to reproducing the problem. *)
module Event: Event = struct

class ['a] structure_read_desc =
object
inherit ['a] C.scalar_eventdesc_impl
method dump f bva = failwith "ouch"
end

end

conscious_data.ml contains:

module type Conscious_data = sig
type 'a eventid

class type formatter =
object
(* The type constraint [>ANY] as 'a is essential to aggravate the problem. *) method format_eventid_tag: 'a . ([>ANY] as 'a) eventid -> unit
end

class type ['a] eventdesc = object
method dump: formatter -> string array -> unit
end

end

(* If I eliminate the :Conscious_data on the next line, the problem goes
away. *)
module Conscious_data: Conscious_data = struct

type 'a eventid = int

class type formatter =
object
method format_eventid_tag: 'a . ([>`ANY] as 'a) eventid -> unit
end

class type ['a] eventdesc = object
method dump: formatter -> string array -> unit
end

end

and conscious.ml contains:

module CD = Conscious_data.Conscious_data
module Conscious = struct

 class virtual ['a] scalar_eventdesc_impl =
 object (self: 'self)
   constraint 'a = [>`ANY]
   method virtual dump: CD.formatter -> string array -> unit
   constraint 'self = [>`ANY] #CD.eventdesc
 end

end

--
Tim Freeman
tim@fungible.com
GPG public key fingerprint ECDF 46F8 3B80 BB9E 575D 7180 76DF FE00 34B1 5C78

@vicuna
Copy link
Author

vicuna commented Sep 13, 2002

Comment author: administrator

Fixed by Jacques (2002-09-11)
See #3655

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