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

suboptimal error message #7663

Closed
vicuna opened this issue Oct 28, 2017 · 3 comments
Closed

suboptimal error message #7663

vicuna opened this issue Oct 28, 2017 · 3 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented Oct 28, 2017

Original bug ID: 7663
Reporter: kosik
Assigned to: @Octachron
Status: resolved (set by @Octachron on 2018-04-04T19:16:46Z)
Resolution: fixed
Priority: low
Severity: minor
Version: 4.05.0
Fixed in version: 4.07.0+dev/beta2/rc1/rc2
Category: typing

Bug description

At some point, when I was trying to compile my program, I got this error message:

Error: Cannot safely evaluate the definition
of the recursively-defined module Foo

Unless the user read Section 7.4 of the reference manual
and deduces that "safe evaluation" might be something closely related to "safe module", I do not think that this error message could be of much help to the user.

Since this topic is subtle (one needs to understand what implementors of Ocaml mean by "safe module" and that this is (somehow) closely related to "safe evaluation" so I think it would make sense if the error message referred the user for further information to the corresponding place (Section 7.4 of the User's Manual).

It would be very helpful if Section 7.4 showed:

  • examples of "unsafe recursive modules"
  • showed what kind of error messages the user then should expect to see
    ("Cannot safely evaluate the definition of the recursively-defined module Foo")
  • and show how, in a given concrete situation, recursive modules can be converted to "safe ones".

The most trivial situation I was able to trigger the error (which confused me completely) is this:

module rec M1 :
sig
val f1 : unit
end = struct
let f1 = ()
let f2 = M2.f1
end

and M2 :
sig
val f1 : unit
end = struct
let f1 = ()
let f2 = M1.f1
end

It would be illustrative to show the necessary workaround that enables one to compile programs like these.
(I.e. changing the type of "M1.f1" to "unit -> unit" or the type of "M2.f1" to "unit -> unit".)

Please consider this as a subjective feedback as this is not really a rigorous area. I am curious what do you think.

@vicuna
Copy link
Author

vicuna commented Oct 31, 2017

Comment author: @Octachron

It sounds very reasonable to me to have a reference to the relevant section of the manual in the error message itself in these subtle cases, and having examples of code raising such errors could be nice.

@vicuna
Copy link
Author

vicuna commented Apr 3, 2018

Comment author: @Octachron

See #1694 .

@vicuna
Copy link
Author

vicuna commented Apr 4, 2018

Comment author: @Octachron

The PR above was merged, fixing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants