Files
mercury/tests/warnings/unused_args_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

43 lines
972 B
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% Predicates to check that unused_args.m is producing the correct warning.
%
%---------------------------------------------------------------------------%
:- module unused_args_test.
:- interface.
:- type switch_test.
:- pred recursive(int::in, switch_test::in, int::in) is semidet.
:- pred nonrecursive(int::in) is semidet.
:- implementation.
:- import_module char.
:- import_module int.
:- type switch_test
---> f1(int)
; f2(char)
; f3.
recursive(Useless, Used1, Used2) :-
(
Used1 = f1(Used2)
;
Used1 = f2(_)
),
nonrecursive(Useless),
Used3 = Used2 + 1,
recursive(Useless, Used1, Used3).
nonrecursive(Useless) :-
(
recursive(Useless, f2('a'), 2)
;
recursive(Useless, f3, 1)
).