mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-23 21:33:49 +00:00
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.
47 lines
1.2 KiB
Mathematica
47 lines
1.2 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% This tests the warnings you should get when a conjunction unifies the same
|
|
% variable with different function symbols. It is a cut-down version of the
|
|
% predicate proc_info_has_io_state_pair_2 from hlds_pred.m, in which the bug
|
|
% marked below took me a long time to find.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module unify_f_g.
|
|
:- interface.
|
|
|
|
:- import_module list.
|
|
:- import_module maybe.
|
|
|
|
:- pred p(list(int)::in, maybe(int)::in, maybe(int)::out,
|
|
maybe(int)::in, maybe(int)::out) is semidet.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int.
|
|
|
|
p([], !In, !Out).
|
|
p([H | T], !In, !Out) :-
|
|
( if H < 10 then
|
|
(
|
|
!.In = no,
|
|
!.In = yes(H) % hard to see bug: !.In should be !:In
|
|
;
|
|
!.In = yes(_),
|
|
fail
|
|
)
|
|
else if H > 20 then
|
|
(
|
|
!.Out = no,
|
|
!:Out = yes(H)
|
|
;
|
|
!.Out = yes(_),
|
|
fail
|
|
)
|
|
else
|
|
fail
|
|
),
|
|
p(T, !In, !Out).
|