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: 5965 Reporter:@gasche Assigned to:@alainfrisch Status: closed (set by @xavierleroy on 2015-12-11T18:18:48Z) Resolution: fixed Priority: normal Severity: minor Target version: 4.00.2+dev Fixed in version: 4.01.0+dev Category: typing Monitored by:@jberdine
Bug description
Using "module type of X" in the definition of the recursive module X is in general rejected by the type-checker:
module rec X : sig
module type S = module type of X (*Error on this occurence*)
end = X
Error: Unbound module X
It happens to somehow work when there is a name conflict with a functor parameter:
module Conflict (X : sig type foo end) = struct
module rec X : sig
module type S = module type of X (* suspect occurrence *)
end = X
end
The code above type-check correctly, but the output of -i is strange, and not consistent with the output of -dtypedtree (the latter being only available in the trunk).
ocamlc -i returns
module Conflict :
functor (X : sig end) ->
sig
module rec X :
sig
module type S = sig
module type S = sig
module type S = sig type foo end
end
end
end
end
Note the triple wrapping module type S = sig module ... which is strange.
(Reproduced on 3.12.1, 4.00.1 and trunk)
Finally, the -dtypedtree output appears to indicate instead that the suspect occurrence of X is understood as a self-reference. Here is the output, curated to remove some noise:
If I understand correctly, you exactly added the first restriction of Xavier's paper on recursive modules ( http://caml.inria.fr/pub/papers/xleroy-recursive_modules-03.pdf ), page 3, that was not necessary before the addition of "module type of" as module names did not appear in signatures (except in "open" and "with module M = .." that seems handled differently).
The approximation phase (step 1) fails if it encounters
one of the following situations:
include module-type in a module signature, in case module-type
refers to one of the recursively-defined module identifiers Xi ;
inherit class-type in a class body type, in case class-type
refers to a class component of one of the recursively-defined
module identifiers X
Original bug ID: 5965
Reporter: @gasche
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:18:48Z)
Resolution: fixed
Priority: normal
Severity: minor
Target version: 4.00.2+dev
Fixed in version: 4.01.0+dev
Category: typing
Monitored by: @jberdine
Bug description
Using "module type of X" in the definition of the recursive module X is in general rejected by the type-checker:
It happens to somehow work when there is a name conflict with a functor parameter:
The code above type-check correctly, but the output of -i is strange, and not consistent with the output of -dtypedtree (the latter being only available in the trunk).
ocamlc -i returns
Note the triple wrapping
module type S = sig module ...
which is strange.(Reproduced on 3.12.1, 4.00.1 and trunk)
Finally, the -dtypedtree output appears to indicate instead that the suspect occurrence of X is understood as a self-reference. Here is the output, curated to remove some noise:
Note that the arguments to
Ptmy_typeof
make reference not to the functor argument X/1009, but to the recursively bound identifier X/1011.This bug was discovered and reported by Arthur Wendling.
The text was updated successfully, but these errors were encountered: