Files
mercury/tests/invalid/coerce_mode_error2.err_exp
Peter Wang 233874403f Improve coerce mode error messages.
compiler/mode_errors.m:
    Replace the two existing options for coerce mode errors with one
    that includes:
    - the path to the input subterm where the error was detected
    - the type of the input subterm
    - the target type that the subterm should be converted to
    - the reason for the error

compiler/modecheck_coerce.m:
    Modify the code to produce the above information.
    Semidet predicates that previously failed when an error is detected
    are changed to det predicates that return the error information.

    In a couple of places where predicates previously would fail,
    we now abort because the conditions should not occur.

compiler/hlds_out_util.m:
    Describe coerce as "coerce expression" (shows up in mode errors).

tests/invalid/Mmakefile:
tests/invalid/coerce_mode_error2.err_exp:
tests/invalid/coerce_mode_error2.m:
    Add test case.

tests/invalid/coerce_clobbered.err_exp:
tests/invalid/coerce_implied_mode.err_exp:
tests/invalid/coerce_instvar.err_exp:
tests/invalid/coerce_int.err_exp:
tests/invalid/coerce_mode_error.err_exp:
tests/invalid/coerce_recursive_inst.err_exp:
tests/invalid/coerce_recursive_type.err_exp:
tests/invalid/coerce_unreachable.err_exp:
    Update expected error messages.
2021-05-17 12:55:58 +10:00

18 lines
1.0 KiB
Plaintext

coerce_mode_error2.m:039: In clause for `test1(out)':
coerce_mode_error2.m:039: in coerce expression:
coerce_mode_error2.m:039: mode error: in the argument term:
coerce_mode_error2.m:039: in the second argument of function symbol `foo':
coerce_mode_error2.m:039: cannot convert the subterm from type
coerce_mode_error2.m:039: `coerce_mode_error2.fruit' to
coerce_mode_error2.m:039: `coerce_mode_error2.citrus' because its
coerce_mode_error2.m:039: instantiatedness includes the function symbols
coerce_mode_error2.m:039: `apple' and `banana'.
coerce_mode_error2.m:050: In clause for `test2(out)':
coerce_mode_error2.m:050: in coerce expression:
coerce_mode_error2.m:050: mode error: cannot convert the argument term from
coerce_mode_error2.m:050: type
coerce_mode_error2.m:050: `coerce_mode_error2.foo(coerce_mode_error2.fruit)'
coerce_mode_error2.m:050: to `coerce_mode_error2.foo_citrus' because its
coerce_mode_error2.m:050: instantiatedness includes the function symbol
coerce_mode_error2.m:050: `nil'.