[m-rev.] for review: more info in diagnostics for subtype errors

Peter Wang novalazy at gmail.com
Wed Jun 30 14:55:59 AEST 2021


On Wed, 30 Jun 2021 12:26:51 +1000 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> Improve diagnostics for subtype errors.
> 
> compiler/add_type.m:
>     Provide more information in error messages for subtype errors.
> 
> library/list.m:
>     Add a utility predicate needed by the new code in add_type.m.
> 
> NEWS:
>     Announce the new predicate in list.m.
> 
> tests/invalid/subtype_invalid_supertype.{m,err_exp}:
>     Add some errors to this test case to exercise new error messages.
> 
> tests/invalid/subtype_abstract.err_exp:
> tests/invalid/subtype_circular.err_exp:
> tests/invalid/subtype_ctor_arg.err_exp:
> tests/invalid/subtype_eqv.err_exp:
> tests/invalid/subtype_exist_constraints.err_exp:
> tests/invalid/subtype_exist_vars.err_exp:
> tests/invalid/subtype_ho.err_exp:
> tests/invalid/subtype_user_compare.err_exp:
> tests/invalid_submodules/subtype_submodule.err_exp:
>     Update the expected outputs for the subtype errors in these test cases.

> diff --git a/NEWS b/NEWS
> index ebe6ee83e..1eda7fe97 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -165,6 +165,7 @@ Changes to the Mercury standard library
>      - pred `delete_nth/3`
>      - pred `foldl7/16`
>      - pred `foldl8/18`
> +    - pred `foldl4_correspondng/11`

corresponding

> diff --git a/library/list.m b/library/list.m
> index ba53d9daf..6f435aab7 100644
> --- a/library/list.m
> +++ b/library/list.m
...
> +    % foldl4_corresponding(F, As, Bs, !Acc1, !Acc2, !Acc3, !Acc4):
> +    % Does the same job as foldl_corresponding, but has three
> +    % accumulators.
> +    %

four accumulators

> diff --git a/tests/invalid/subtype_abstract.err_exp b/tests/invalid/subtype_abstract.err_exp
> index daf90e683..0bba6b4f3 100644
> --- a/tests/invalid/subtype_abstract.err_exp
> +++ b/tests/invalid/subtype_abstract.err_exp
> @@ -1,5 +1,7 @@
> -subtype_abstract.m:012: Error: the type definition for `citrus'/0 is not
> -subtype_abstract.m:012:   visible here.
> -subtype_abstract.m:019: Error: `subtype_abstract.lemon' is not a subtype of the
> -subtype_abstract.m:019:   corresponding type `subtype_abstract.fruit' in the
> -subtype_abstract.m:019:   supertype.
> +subtype_abstract.m:012: Error: the type definition for `citrus'/0,
> +subtype_abstract.m:012:   the super type of `lemon'/0,
> +subtype_abstract.m:012:   is not visible here.

Perhaps it would be an improvement to add the word "declared", as in:

    Error: the type definition for `citrus'/0,
      the declared super type of `lemon'/0,
      is not visible here.

It's not necessary, though.

The rest looks fine.

Peter


More information about the reviews mailing list