mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 03:13:40 +00:00
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.
15 lines
816 B
Plaintext
15 lines
816 B
Plaintext
nullary_ho_func_error.m:026: In clause for predicate `main'/2:
|
|
nullary_ho_func_error.m:026: in argument 1 of call to predicate `print'/3:
|
|
nullary_ho_func_error.m:026: in argument 1 of functor `apply_nullary_func/1':
|
|
nullary_ho_func_error.m:026: type error in unification of argument
|
|
nullary_ho_func_error.m:026: and constant `pi'.
|
|
nullary_ho_func_error.m:026: argument has type `func = T',
|
|
nullary_ho_func_error.m:026: constant `pi' has type `float'.
|
|
nullary_ho_func_error.m:026: The partial type assignment was:
|
|
nullary_ho_func_error.m:026: DCG_0_3: io.state
|
|
nullary_ho_func_error.m:026: DCG_1_4: io.state
|
|
nullary_ho_func_error.m:026: DCG_3_6: io.state
|
|
nullary_ho_func_error.m:026: V_7: string
|
|
nullary_ho_func_error.m:026: V_8: T
|
|
nullary_ho_func_error.m:026: V_9: ((func) = T)
|