Files
mercury/tests/warnings/inference_test.m
Zoltan Somogyi 83dc913329 Update the style of the warnings test cases.
tests/warnings/*.m:
    Bring the programming style of these modules up to date,
    except where the problem being tested for seems to be related
    to the old programming style

    In the infinite_recursion test case, add code that we *should*
    warn about, but currently don't.

tests/warnings/*.m:
    Update the expected outputs to account for the changes in line
    numbers, and the fact that the compiler computes the contexts
    of (if C then T else E) if-then-elses differently from (C -> T; E)
    if-then-else (it takes the context of the "then" vs the context
    of the ";").

    Delete arg_order_rearrangment.exp2. It was long unused, but
    deleting it in CVS would not have allowed us to put it back later.
2019-04-20 09:37:37 +10:00

44 lines
912 B
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% This test case isn't really testing warnings,
% it is actually testing that the compiler
% prints out the right type/mode inference message.
%
%---------------------------------------------------------------------------%
:- module inference_test.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module int.
:- import_module list.
main(!IO) :-
io.print(len_func([42]), !IO),
io.nl(!IO).
len_func(List) = Len :-
len(List, Len).
len([], zero).
len([_ | Xs], N) :-
len(Xs, N - 1).
:- typeclass null(T) where [
func zero = T
].
:- instance null(int) where [
func(zero/0) is int_zero
].
int_zero = 0.
unused_pred([X], [_]) :-
X = zero.