Files
mercury/tests/invalid/arith_wrong_module.err_exp
Zoltan Somogyi 4bf9b33481 Warn about the need to import intN/uintN modules.
compiler/typecheck_errors.m:
    When we are reporting a type error in a var-functor unification
    where the functor is the name of a function defined in library/int.m,
    such as A = B - C or D = E + F, check whether

    (a) the types of any of the variables involved in the error, *and*
    (b) the expected argument or result types involved

    are builtin integer types whose modules have NOT been imported.
    If so, then add a note to the error message that points out
    that operations on these type(s) require importing the corresponding
    modules.

    Do the same when reporting type errors in calls to predicates
    whose name is the name of a predicate defined in library/int.m.

    Fix an old ZZZ.

compiler/type_assign.m:
    Fix typo in a (so far unused) field name.

tests/invalid/arith_wrong_module.{m,err_exp}:
    A new test case with three errors, which respectively test the changes
    to the three error-message-generating predicates modified by this diff.

tests/invalid/Mmakefile:
    Enable the new test case.
2022-11-25 03:18:29 +11:00

45 lines
2.3 KiB
Plaintext

arith_wrong_module.m:022: In clause for predicate `test_func'/3:
arith_wrong_module.m:022: type error in unification of variable `C'
arith_wrong_module.m:022: and functor `+'/2.
arith_wrong_module.m:022: variable `C' has type
arith_wrong_module.m:022: uint32,
arith_wrong_module.m:022: functor `+'/2 has type
arith_wrong_module.m:022: `+'(int, int): int.
arith_wrong_module.m:022: Note that operations on values of type `uint32' are
arith_wrong_module.m:022: available only if the `uint32' module is imported.
arith_wrong_module.m:025: In clause for predicate `test_pred'/3:
arith_wrong_module.m:025: in call to predicate `int.pow'/3:
arith_wrong_module.m:025: in argument 1:
arith_wrong_module.m:025: variable `A' has type
arith_wrong_module.m:025: int16,
arith_wrong_module.m:025: expected type was
arith_wrong_module.m:025: int;
arith_wrong_module.m:025: in argument 2:
arith_wrong_module.m:025: variable `B' has type
arith_wrong_module.m:025: uint16,
arith_wrong_module.m:025: expected type was
arith_wrong_module.m:025: int;
arith_wrong_module.m:025: in argument 3:
arith_wrong_module.m:025: variable `C' has type
arith_wrong_module.m:025: int16,
arith_wrong_module.m:025: expected type was
arith_wrong_module.m:025: int.
arith_wrong_module.m:025: Note that operations on values of types `int16' and
arith_wrong_module.m:025: `uint16' are available only if the `int16' and
arith_wrong_module.m:025: `uint16' modules respectively are imported.
arith_wrong_module.m:028: In clause for predicate `game_loop'/4:
arith_wrong_module.m:028: in unification of variable `Diff'
arith_wrong_module.m:028: and term `(End - Start)':
arith_wrong_module.m:028: type error in arguments of functor `-'/2.
arith_wrong_module.m:028: Argument 1 (End) has type
arith_wrong_module.m:028: int64,
arith_wrong_module.m:028: expected type was
arith_wrong_module.m:028: int.
arith_wrong_module.m:028: Argument 2 (Start) has type
arith_wrong_module.m:028: int64,
arith_wrong_module.m:028: expected type was
arith_wrong_module.m:028: int.
arith_wrong_module.m:028: Note that operations on values of type `int64' are
arith_wrong_module.m:028: available only if the `int64' module is imported.
For more information, recompile with `-E'.