[m-rev.] for review: Warn about redundant type conversions.

Julien Fischer jfischer at opturion.com
Fri Jun 28 15:54:25 AEST 2024


On Thu, 27 Jun 2024 at 17:04, Peter Wang <novalazy at gmail.com> wrote:
>
> Warn about type conversion expressions, i.e. coerce(),
> where the type of the argument and the type of the expression
> are the same.
>
> compiler/options.m:
>     Add a new option --warn-redundant-coerce, enabled by default.
>
> compiler/type_assign.m:
>     Add a coerce_constraint_status value to indicate that a coercion
>     is known to be type-correct but redundant.
>
> compiler/typecheck.m:
>     Generate warnings for redundant coercions, once typechecking has
>     narrowed down to a single type assignment.
>
> compiler/typecheck_clauses.m:
>     Check for and record redundant coercions the type assignment.

That sentence doesn't make sense, do you mean *in* the type assignment?

>     Note down a bug in the way we process coerce constraints.
>     This can cause the compiler to arbitrarily pick a valid
>     assignment of types to type variables, when other equally valid
>     possibilities exist.
>
> compiler/typecheck_errors.m:
>     Delete incorrect error messages that said you cannot coerce from a
>     given type to itself.
>
>     Add predicate to generate a warning for a redundant coercion.

The rest looks fine.

Julien.


More information about the reviews mailing list