[m-dev.] "Did you mean ..." messages for module qualifiers
Zoltan Somogyi
zoltan.somogyi at runbox.com
Mon Jan 13 22:54:50 AEDT 2025
On Mon, 13 Jan 2025 22:45:36 +1100, Julien Fischer <jfischer at opturion.com> wrote:
> Hi Zoltan,
>
> On Mon, 13 Jan 2025 at 16:59, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
> >
> > On Mon, 13 Jan 2025 16:26:33 +1100, Julien Fischer <jfischer at opturion.com> wrote:
> > > Currently, if a module qualified name has a module qualifier that does not
> > > match one of the imported modules, or the module being compiled, we generate
> > > an error message like the following:
> > >
> > > foo.m:013: In clause for predicate `main'/2:
> > > foo.m:013: error: call to undefined predicate `range.bar'/2.
> > > foo.m:013: (The module `range' has not been imported.)
> > >
> > > The module `range' not being imported is one possible cause for this error.
> > > Another possible cause for this error, as here, is that the user has
> > > incorrectly typed the name of a module (in this case `ranges'). In my opinion,
> > > some form of the "Did you mean ..." messages we generate in other circumstances
> > > would be also be useful here, if we find a unrecognised module qualifier we
> > > compute its distance from the names of the visible modules and report any that
> > > are close enough.
> > >
> > > Question: should we generate "Did you mean ..." messages for module qualifiers?
> >
> > Yes, if we can. Generating dym messages requires knowing either *the* set of
> > possible spellings you may mean, or a reasonable subset of that set. In this case,
> > I am pretty sure that the compiler does NOT (currently) have access to the full
> > set of module names in the program. It does have access to the subset of that set
> > consisting of the set of imported and included module names, but that would not help
> > in this case.
>
> I disagree, if the unknown qualifier is within a sufficiently close
> edit distance of some of
> the imported or included modules, then it is very probable that the
> user meant the
> qualifier to be of one of those and just entered it incorrectly.
Agreed, but your email did not say anything about the ranges module being
imported, so I assumed it wasn't.
> > Whether that would be big enough for dym messages to be useful depends on
> > the kinds of misspellings people tend to write, and that is quite individual-dependent.
>
> I think we would probably limit it to candidates that are within one
> or two edits of the
> unknown name.
We do not do so for other kinds of dym messages. The heuristic for "how big
a difference is too big" is something we took from (I think) gcc, and it is
dependent on name length, I think about one third replacement being the limit.
Zoltan.
More information about the developers
mailing list