[m-rev.] for review: Include variable name in coerce type error messages.

Peter Wang novalazy at gmail.com
Tue Jul 2 18:51:44 AEST 2024


On Tue, 02 Jul 2024 17:53:52 +1000 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> 
> On 2024-07-02 17:24 +10:00 AEST, "Peter Wang" <novalazy at gmail.com> wrote:
> > 
> > Writing
> > 
> >     error: cannot coerce [the term bound to] `X' from ...
> > or
> >     warning: type conversion of [the term bound to] `X' from ...
> > 
> > seems too long-winded, so I've omitted the bracketed words.
> > Do the messages give the impression that variables can somehow change
> > types? Suggestions welcome.
> 
> I agree that is a concern, but I also can't think of wording that would
> avoid that misleading impression yet is short and direct enough.
> 
> > ----
> > 
> > compiler/typecheck.m:
> > compiler/typecheck_errors.m:
> >     As above.
> 
> What is above? Not your question, surely.
> 

git send-email uses the first line of the commit message as the subject
of the email. I should have duplicated it for "As above." to make sense.

> > --- a/tests/invalid/coerce_non_du.err_exp
> > +++ b/tests/invalid/coerce_non_du.err_exp
> > @@ -1,22 +1,22 @@
> >  coerce_non_du.m:015: In clause for function `f1'/1:
> > -coerce_non_du.m:015:   error: cannot coerce from `int' to `int'.
> > +coerce_non_du.m:015:   error: cannot coerce `X' from `int' to `int'.
> >  coerce_non_du.m:015:   You can only coerce from one discriminated union type to
> >  coerce_non_du.m:015:   another, and `int' is a builtin type.
> 
> This reports the error for an int->X coercion, but leaves out the warning for the X->X coercion,
> making it the elephant in the room. I would either leave out the part of the message that
> reports the coerced-to type, or add an addendum about the coercion being redundant as well as
> erroneous. I would prefer the latter, but can live with the former.

The references to int and X had me confused for a while.
So for an invalid coercion from one type to the same type,
we should mention that it would be redundant anyway. Ok.

Peter


More information about the reviews mailing list