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

Error message for module used where a module type is expected is confusing #6633

Closed
vicuna opened this issue Oct 27, 2014 · 10 comments · Fixed by #9673
Closed

Error message for module used where a module type is expected is confusing #6633

vicuna opened this issue Oct 27, 2014 · 10 comments · Fixed by #9673

Comments

@vicuna
Copy link

vicuna commented Oct 27, 2014

Original bug ID: 6633
Reporter: @whitequark
Status: acknowledged (set by @damiendoligez on 2014-12-22T20:51:24Z)
Resolution: open
Priority: normal
Severity: feature
Version: 4.02.1
Target version: undecided
Category: typing
Monitored by: @gasche

Bug description

E.g.:

equal.ml:

  module type Equal = sig .. end

foo.ml:

  module Foo = Functor (Equal : Equal) -> struct .. end

Actual: Error: Unbound module type Equal
Expected: something like Equal is a module and it cannot be used as module type

@vicuna
Copy link
Author

vicuna commented Oct 27, 2014

Comment author: @garrigue

The message is correct: there is indeed no module type Equal in scope inside foo.ml.
Moreover, since the name spaces for modules and module types are distinct, the fact there is a module Equal does not seem to be relevant here. I don't see in which way the suggested message would improve.
I we were to visit all imported modules, one could attempt to say that there is indeed a module type Equal.Equal, but looking for it can be very expensive.

@vicuna
Copy link
Author

vicuna commented Oct 28, 2014

Comment author: @whitequark

Well, I suppose it makes sense. I'm reporting on behalf on someone from IRC, who found it confusing. I do find the fact that modules and module types have different namespaces confusing, as well.

@vicuna
Copy link
Author

vicuna commented Dec 22, 2014

Comment author: @damiendoligez

Maybe it would make sense to append a note saying that there is a module by that name, but it's not a module type, as an extension of the spell-checking idea.

Indeed all these namespaces are sometimes confusing.

@vicuna
Copy link
Author

vicuna commented Dec 22, 2014

Comment author: @whitequark

I like this solution.

@github-actions
Copy link

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label May 11, 2020
@whitequark
Copy link
Member

Still an issue.

@garrigue
Copy link
Contributor

Anybody has a PR for this?

@Drup
Copy link
Contributor

Drup commented May 21, 2020

(I think we should have a label for not-so-difficult-to-improve error messages)

@gasche
Copy link
Member

gasche commented May 21, 2020

We have newcomer-job-advanced for things that are accessible to people unfamiliar with the compiler codebase, but that still require an "advanced" OCaml programming level and/or dealing with a somewhat complex problem. If you think it applies here, it could act as a superset of your label idea. (And if it does not, it's not clear what "not so difficult" means.)

(Usually when we apply the label we also explain what said newcomer should look at to attack the issue: the broad lines of what we would do ourselves to solve it, starting with which files to look for modification or documentation.)

@Drup
Copy link
Contributor

Drup commented May 21, 2020

Sounds good. Can you add it ?

I think this one is pretty straightforward: the error message is created in Typemod.report_error. When formatting such lookup module type error, we simply need to look in the environment if a module of the same name exists and return an "advice" (attached to the original error). A similar approach is already implemented for spelling suggestions.

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

Successfully merging a pull request may close this issue.

5 participants