Files
mercury/tests/hard_coded/loop_inv_test4.m
Peter Wang 25c0cebc4d Fix bug #145.
Branches: main, 10.04

Fix bug #145.

compiler/loop_inv.m:
        Fix a bug wherein the variable holding the higher order term being
        called was not considered a goal input.  Hence the goal may be
        incorrectly considered loop-invariant.

tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
tests/hard_coded/loop_inv_test4.exp:
tests/hard_coded/loop_inv_test4.m:
        Add test case.

        Enable loop_inv_test3 which seems to have been left out accidentally.
2010-04-21 04:50:28 +00:00

39 lines
1.1 KiB
Mathematica

%-----------------------------------------------------------------------------%
% Regression test. The variable holding the higher order term being called was
% not considered a goal input. Hence the goal may be incorrectly considered
% loop-invariant.
:- module loop_inv_test4.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- implementation.
:- import_module list.
:- import_module int.
%-----------------------------------------------------------------------------%
main(!IO) :-
List = [int.plus, int.times, int.minus],
use_list(List, !IO).
:- type myfunc == (func(int, int) = int).
:- pred use_list(list(myfunc)::in, io::di, io::uo) is det.
use_list([], !IO).
use_list([P | Ps], !IO) :-
X = P(5, 1),
io.write_int(X, !IO),
io.write_string("\n", !IO),
use_list(Ps, !IO).
%-----------------------------------------------------------------------------%
% vim: ft=mercury ts=8 sts=4 sw=4 et