Files
mercury/tests/invalid/arith_wrong_module.m
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

32 lines
810 B
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
:- module arith_wrong_module.
:- interface.
:- import_module io.
:- pred test_func(uint32::in, uint32::in, uint32::out) is det.
:- pred test_pred(int16::in, uint16::in, int16::out) is det.
:- pred game_loop(int64::in, int64::in, io::di, io::uo) is det.
:- implementation.
:- import_module int.
:- import_module list.
:- import_module string.
test_func(A, B, C) :-
C = A + B.
test_pred(A, B, C) :-
pow(A, B, C).
game_loop(Start, End, !IO) :-
Diff = End - Start,
io.stdout_stream(StdOut, !IO),
io.format(StdOut, "start: %di, end: %i, diff: %i\n",
[i64(Start), i64(End), i64(Diff)], !IO).