Files
mercury/tests/invalid/bug197.err_exp
Zoltan Somogyi f52d2381cc Make pred/func types more readable in error messages.
Until now, mismatches between expected and actual types, when they were
higher order types, got reported like this (the motivating example):

handle_options.m:158: In clause for predicate `process_given_options'/8:
handle_options.m:158:   in argument 3 of functor `option_ops_userdata/3':
handle_options.m:158:   type error in unification of argument
handle_options.m:158:   and constant `special_handler'.
handle_options.m:158:   argument has type `pred(libs.options.option,
handle_options.m:158:   getopt_io.special_data,
handle_options.m:158:   tree234.tree234(libs.options.option,
handle_options.m:158:   getopt_io.option_data),
handle_options.m:158:   getopt_io.maybe_option_table(libs.options.option),
handle_options.m:158:   UserDataType, UserDataType)',
handle_options.m:158:   constant `special_handler' has type
handle_options.m:158:   `pred(libs.options.option, getopt_io.special_data,
handle_options.m:158:   tree234.tree234(libs.options.option,
handle_options.m:158:   getopt_io.option_data),
handle_options.m:158:   getopt_io.maybe_option_table(libs.options.option))'.

This is hard to read

- because there is no visual break between the expected and the actual type,
  and

- because the different initial prefixes before the starts of the types
  prevent corresponding argument types in the expected and actual types
  from lining up.

compiler/typecheck_errors.m:
    Fix the above by always putting the argument types of higher order values
    on lines of their own in such error messages. One side effect of this is
    that we don't wrap predicate types in parentheses. (The parentheses' job
    is to prevent unwanted interactions with surrounding code, but in
    error messages, there *is* no surrounding code.)

    Reorder the argument lists of some predicates and functions
    to let them be used as the first argument of list.map.

compiler/parse_tree_to_term.m:
    Delete a predicate that duplicates another predicate.

tests/invalid/ho_type_arity_bug.{m,err_exp}:
    A new test case for the updated error message format.

tests/invalid/Mmakefile:
    Enable the new test case.

tests/invalid/bug197.err_exp:
tests/invalid/nullary_ho_func_error.err_exp:
tests/invalid/type_error_ambiguous.err_exp:
tests/invalid/types2.err_exp:
tests/invalid_purity/impure_func_t5.err_exp:
tests/invalid_purity/impure_pred_t1.err_exp:
tests/invalid_purity/impure_pred_t1_fixed.err_exp:
tests/invalid_purity/impure_pred_t2.err_exp:
tests/invalid_purity/purity_nonsense.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
    Expect updated error messages.
2020-09-25 14:38:58 +10:00

26 lines
1.0 KiB
Plaintext

bug197.m:023: Error: no clauses for predicate `foo'/4.
bug197.m:025: Error: clause for predicate `foo'/3
bug197.m:025: without corresponding `:- pred' declaration.
bug197.m:025: However, a predicate of that name does exist with arity 4.
bug197.m:026: In clause for predicate `foo'/3:
bug197.m:026: in argument 1 of call to predicate `list.foldl'/4:
bug197.m:026: type error: argument has type `pred(
bug197.m:026: string,
bug197.m:026: T,
bug197.m:026: V_6,
bug197.m:026: V_6
bug197.m:026: )',
bug197.m:026: expected type was `pred(
bug197.m:026: L,
bug197.m:026: A,
bug197.m:026: A
bug197.m:026: )'.
bug197.m:031: Error: cannot use !:SS here due to the surrounding lambda
bug197.m:031: expression; you may only refer to !.SS.
bug197.m:026: Here is the surrounding context that makes state variable SS
bug197.m:026: readonly.
bug197.m:031: In clause for predicate `foo'/3:
bug197.m:031: warning: variable `STATE_VARIABLE_SS_20' occurs only once in
bug197.m:031: this scope.
For more information, recompile with `-E'.