You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5703 Reporter: cgillot Assigned to:@garrigue Status: closed (set by @xavierleroy on 2017-02-16T14:16:26Z) Resolution: won't fix Priority: normal Severity: minor Target version: later Category: typing Tags: recmod Monitored by: mandrykin
Bug description
I have a class hierarchy, each class being wrapped in its own module.
When using regular modules, everything compiles just fine ; but recursive modules trigger typing failure.
$ cat test.ml
module rec Ma : sig
class a : int -> object
method as_a : int
method z : int
end
end = struct
class a x = object(this)
method as_a : int = x
method z : int = 50
end
end
and Mb : sig
class b : int -> object
method as_b : int
inherit Ma.a
end
end = struct
class b =
let z = 50 in
fun x -> object(this)
method as_b : int = x
inherit Ma.a z as a
end
end
and Mc : sig
class c : int -> object
method as_c : int
inherit Mb.b
end
end = struct
class c =
let u = 42 in
fun x -> object(this)
method as_c : int = x
inherit Mb.b u as b
end
end
$ ocamlc test.ml
File "test.ml", line 31, characters 6-129:
Error: Signature mismatch:
...
Class declarations do not match:
class c :
int ->
object
method as_a : int
method as_b : int
method as_c : int
method z : int
end
does not match
class c : int -> object method as_b : int method as_c : int end
The public method as_a cannot be hidden
The public method z cannot be hidden
This error never appears with regular modules (even with explicit signatures) ; and this only happens when there are at least 3 classes.
Also bumped into this issue in PPX generated code. It can be worked around by inheriting from a common class type containing all method signatures listed in all the modules. Also attached a minimal example.
This comes from the fact recursive modules are supposed to be typable in any order, just like if you compare
let f x = ...
let g x = ...
let h x = ...
and
let rec f x = ...
and g x = ...
and h x = ...
Recursive modules are both stronger (you can refer to all other modules) and weaker (these references carry less information).
For let and let rec this is similar; using let rec you only have access to the monomorphic versions of the other functions.
Original bug ID: 5703
Reporter: cgillot
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2017-02-16T14:16:26Z)
Resolution: won't fix
Priority: normal
Severity: minor
Target version: later
Category: typing
Tags: recmod
Monitored by: mandrykin
Bug description
I have a class hierarchy, each class being wrapped in its own module.
When using regular modules, everything compiles just fine ; but recursive modules trigger typing failure.
$ cat test.ml
module rec Ma : sig
class a : int -> object
method as_a : int
method z : int
end
end = struct
class a x = object(this)
method as_a : int = x
method z : int = 50
end
end
and Mb : sig
class b : int -> object
method as_b : int
inherit Ma.a
end
end = struct
class b =
let z = 50 in
fun x -> object(this)
end
end
and Mc : sig
class c : int -> object
method as_c : int
inherit Mb.b
end
end = struct
class c =
let u = 42 in
fun x -> object(this)
end
end
$ ocamlc test.ml
File "test.ml", line 31, characters 6-129:
Error: Signature mismatch:
...
Class declarations do not match:
class c :
int ->
object
method as_a : int
method as_b : int
method as_c : int
method z : int
end
does not match
class c : int -> object method as_b : int method as_c : int end
The public method as_a cannot be hidden
The public method z cannot be hidden
This error never appears with regular modules (even with explicit signatures) ; and this only happens when there are at least 3 classes.
Additional information
Ocaml version : trunk, revision 12787
File attachments
The text was updated successfully, but these errors were encountered: