[m-rev.] for review: improve actual/expected diagnostics

Julien Fischer jfischer at opturion.com
Thu Feb 2 15:27:57 AEDT 2023


On Thu, 2 Feb 2023, Zoltan Somogyi wrote:

> Improve actual/expected mismatch diagnostics.
> 
> compiler/typecheck_errors.m:
>     Improve the diagnostics we generate for mismatches between actual and
>     expected types. If the mismatch was between a single actual type and
>     a single expected type, we already printed a message whose format
>     was specialized for that case, but in every other case, we fell back
>     to a more general but less readable error message template. Improve on this
>     by splitting the task into two halves, one for the actual type(s) and one
>     for the expected type(s), each of which generates simpler text if
>     there is only one such type.
>
>     Separate the actual type part of the diagnostic from the expected type part
>     using a semicolon instead of a comma, because we now use commas to
>     separate multiple actual types from each other, and multiple expected
>     types from each other.
>
>     Don't insist on putting a newline after the "type error:" part of the
>     diagnostic.
>
>     Do all of the above in just one predicate, factoring out code that
>     used to be duplicated.
>
>     Delete a function that has never been used. (I added it around 2008
>     for later use by a student working on software transactional memory,
>     but that use never happened.) This used to contain a third copy
>     of the code that was factored out.
>
>     For functions that used to take both a typecheck_info and a
>     type_error_clause_context, delete the latter argument, since the caller
>     invariably took it out of the typecheck_info that it also passed.
> 
> compiler/typecheck.m:
>     Don't pass now-unneeded type_error_clause_contexts.
> 
> compiler/typecheck_error_type_assign.m:
>     Fix typo in a field name.

That's fine.

Julien.


More information about the reviews mailing list