Full explanation for unsafe cycles in recursive modules #2058
This PR proposes to expand the error message for unsafe cycles in recursive module definition by providing an example of unsafe components for each unsafe module in the cycle.
For instance, the error message for
module rec A: sig module F: functor(X:sig end) -> sig end val f: unit -> unit end = struct module F(X:sig end) = struct end let f () = B.value end and B: sig val value: unit end = struct let value = A.f () end
is expanded with two new lines:
In term of implementation, this PR merely keep track of the unsafe components detected during the
Hopefully, pointing the unsafe components would make it easier for users to fix the problematic cycle, (particularly when the cycle contains exotic unsafe components).
A pure aside: it might be nice if error messages slowly started to follow the Gnu/FSF standard so that generic tools that parse compiler output would need less customization. See: https://www.gnu.org/prep/standards/html_node/Errors.html for details. That said, it is not necessary that this PR do that, I'm just reminded of it now.