Improve mode error messages a bit more.

compiler/mode_errors.m:
    Simplify the wording of the new error message component added yesterday.

    Mention a possible reason for inst mismatches when the inst contains
    a higher order component. Put this in the parentheses, because it is
    *not* guaranteed to be the actual reason.

compiler/inst_util.m:
    Add a utility predicate for the new code in mode_errors.m.

tests/invalid/any_passed_as_ground.err_exp:
tests/invalid/constrained_poly_insts2.err_exp:
tests/invalid/ho_type_mode_bug.err_exp:
tests/invalid/try_detism.err_exp:
    Expect the updated error messages.
This commit is contained in:
Zoltan Somogyi
2020-01-24 16:26:24 +11:00
parent b831562958
commit e9ad852183
6 changed files with 141 additions and 24 deletions

View File

@@ -6,6 +6,6 @@ any_passed_as_ground.m:029: free,
any_passed_as_ground.m:029: any
any_passed_as_ground.m:029: which does not match any of the modes for
any_passed_as_ground.m:029: predicate `list.member'/2.
any_passed_as_ground.m:029: The second argument `Xs', whose inst is `any',
any_passed_as_ground.m:029: The second argument `Xs' has inst `any', which
any_passed_as_ground.m:029: does not match any of those modes.
For more information, recompile with `-E'.

View File

@@ -20,8 +20,8 @@ constrained_poly_insts2.m:049: inst:
constrained_poly_insts2.m:049: ground
constrained_poly_insts2.m:049: which does not match any of the modes for
constrained_poly_insts2.m:049: higher-order predicate call.
constrained_poly_insts2.m:049: The first argument `X', whose inst is
constrained_poly_insts2.m:049: `ground', does not match any of those modes.
constrained_poly_insts2.m:049: The first argument `X' has inst `ground',
constrained_poly_insts2.m:049: which does not match any of those modes.
constrained_poly_insts2.m:054: In clause for `p2((pred(in((I =< ground))) is
constrained_poly_insts2.m:054: det), in((J =<
constrained_poly_insts2.m:054: (constrained_poly_insts2.apple))))':
@@ -36,13 +36,13 @@ constrained_poly_insts2.m:054: apple
constrained_poly_insts2.m:054: ) )
constrained_poly_insts2.m:054: which does not match any of the modes for
constrained_poly_insts2.m:054: higher-order predicate call.
constrained_poly_insts2.m:054: The first argument `X', whose inst is
constrained_poly_insts2.m:054: The first argument `X' has inst
constrained_poly_insts2.m:054: ( J =< named inst apple,
constrained_poly_insts2.m:054: which expands to
constrained_poly_insts2.m:054: bound(
constrained_poly_insts2.m:054: apple
constrained_poly_insts2.m:054: ) ),
constrained_poly_insts2.m:054: does not match any of those modes.
constrained_poly_insts2.m:054: which does not match any of those modes.
constrained_poly_insts2.m:059: In clause for `p3((pred(in((I =<
constrained_poly_insts2.m:059: (constrained_poly_insts2.apple)))) is det),
constrained_poly_insts2.m:059: in((constrained_poly_insts2.orange)))':
@@ -74,13 +74,13 @@ constrained_poly_insts2.m:064: apple
constrained_poly_insts2.m:064: ) )
constrained_poly_insts2.m:064: which does not match any of the modes for
constrained_poly_insts2.m:064: higher-order predicate call.
constrained_poly_insts2.m:064: The first argument `X', whose inst is
constrained_poly_insts2.m:064: The first argument `X' has inst
constrained_poly_insts2.m:064: ( J =< named inst apple,
constrained_poly_insts2.m:064: which expands to
constrained_poly_insts2.m:064: bound(
constrained_poly_insts2.m:064: apple
constrained_poly_insts2.m:064: ) ),
constrained_poly_insts2.m:064: does not match any of those modes.
constrained_poly_insts2.m:064: which does not match any of those modes.
constrained_poly_insts2.m:069: In clause for `p5((pred(in((I =<
constrained_poly_insts2.m:069: (constrained_poly_insts2.apple)))) is det),
constrained_poly_insts2.m:069: in((constrained_poly_insts2.apple)))':
@@ -95,10 +95,10 @@ constrained_poly_insts2.m:069: apple
constrained_poly_insts2.m:069: )
constrained_poly_insts2.m:069: which does not match any of the modes for
constrained_poly_insts2.m:069: higher-order predicate call.
constrained_poly_insts2.m:069: The first argument `X', whose inst is
constrained_poly_insts2.m:069: The first argument `X' has inst
constrained_poly_insts2.m:069: named inst apple,
constrained_poly_insts2.m:069: which expands to
constrained_poly_insts2.m:069: bound(
constrained_poly_insts2.m:069: apple
constrained_poly_insts2.m:069: ),
constrained_poly_insts2.m:069: does not match any of those modes.
constrained_poly_insts2.m:069: which does not match any of those modes.

View File

@@ -25,12 +25,16 @@ ho_type_mode_bug.m:029: free,
ho_type_mode_bug.m:029: free
ho_type_mode_bug.m:029: which does not match any of the modes for predicate
ho_type_mode_bug.m:029: `ho_type_mode_bug.my_foldl2'/6.
ho_type_mode_bug.m:029: The first argument `P', whose inst is
ho_type_mode_bug.m:029: `(pred(in, in, out) is det)', does not match any of
ho_type_mode_bug.m:029: those modes.
ho_type_mode_bug.m:029: The third argument `FirstAcc1', whose inst is `free',
ho_type_mode_bug.m:029: The first argument `P' has inst
ho_type_mode_bug.m:029: `(pred(in, in, out) is det)', which does not match
ho_type_mode_bug.m:029: any of those modes.
ho_type_mode_bug.m:029: (For higher order insts like this, the mismatch is
ho_type_mode_bug.m:029: sometimes caused by the arity of the predicate or
ho_type_mode_bug.m:029: function being different in the inst than in the
ho_type_mode_bug.m:029: type.)
ho_type_mode_bug.m:029: The third argument `FirstAcc1' has inst `free', which
ho_type_mode_bug.m:029: does not match any of those modes.
ho_type_mode_bug.m:029: The fifth argument `SecAcc1', whose inst is `free',
ho_type_mode_bug.m:029: The fifth argument `SecAcc1' has inst `free', which
ho_type_mode_bug.m:029: does not match any of those modes.
ho_type_mode_bug.m:029:
ho_type_mode_bug.m:027: In clause for `my_foldl2((pred(in, in, out) is det),
@@ -75,12 +79,16 @@ ho_type_mode_bug.m:029: free,
ho_type_mode_bug.m:029: free
ho_type_mode_bug.m:029: which does not match any of the modes for predicate
ho_type_mode_bug.m:029: `ho_type_mode_bug.my_foldl2'/6.
ho_type_mode_bug.m:029: The first argument `P', whose inst is
ho_type_mode_bug.m:029: `(pred(in, in, out) is det)', does not match any of
ho_type_mode_bug.m:029: those modes.
ho_type_mode_bug.m:029: The third argument `FirstAcc1', whose inst is `free',
ho_type_mode_bug.m:029: The first argument `P' has inst
ho_type_mode_bug.m:029: `(pred(in, in, out) is det)', which does not match
ho_type_mode_bug.m:029: any of those modes.
ho_type_mode_bug.m:029: (For higher order insts like this, the mismatch is
ho_type_mode_bug.m:029: sometimes caused by the arity of the predicate or
ho_type_mode_bug.m:029: function being different in the inst than in the
ho_type_mode_bug.m:029: type.)
ho_type_mode_bug.m:029: The third argument `FirstAcc1' has inst `free', which
ho_type_mode_bug.m:029: does not match any of those modes.
ho_type_mode_bug.m:029: The fifth argument `SecAcc1', whose inst is `free',
ho_type_mode_bug.m:029: The fifth argument `SecAcc1' has inst `free', which
ho_type_mode_bug.m:029: does not match any of those modes.
ho_type_mode_bug.m:029:
ho_type_mode_bug.m:027: In clause for `my_foldl2((pred(in, in, out) is det),

View File

@@ -18,7 +18,10 @@ try_detism.m:016: unique,
try_detism.m:016: free
try_detism.m:016: which does not match any of the modes for predicate
try_detism.m:016: `exception.try_io'/4.
try_detism.m:016: The first argument `TryLambda', whose inst is
try_detism.m:016: The first argument `TryLambda' has inst
try_detism.m:016: /* unique */ (pred(out, di, uo) is semidet),
try_detism.m:016: does not match any of those modes.
try_detism.m:016: which does not match any of those modes.
try_detism.m:016: (For higher order insts like this, the mismatch is
try_detism.m:016: sometimes caused by the arity of the predicate or function
try_detism.m:016: being different in the inst than in the type.)
For more information, recompile with `-E'.