Files
mercury/tests/warnings/singleton_test_state_var.m
Zoltan Somogyi 678b226be8 Generate messages for some state var singletons.
compiler/state_var.m:
    Delete redundant copy unifications, whose mere presence can hide the fact
    that the state variable instance being copied is a singleton.

compiler/add_clause.m:
    Conform to the change in state_var.m.

compiler/hlds_goal.m:
    Add a new goal feature for state_var.m to use to identify the copy goals
    inserted by the state var transformation.

    Add a mechanism to add more than feature to a goal at a time.

compiler/saved_vars.m:
    Conform to the change to hlds_goal.m.

compiler/proc_gen.m:
    Fix a singleton ocurrence of a state variable. This problem was hidden
    until the bug fix in state_var.m described above.

tests/warnings/singleton_test_state_var.{m,exp}:
    New regression test to test for the original bug.

tests/warnings/Mmakefile:
    Enable the new test case.
2018-03-09 14:10:50 +11:00

20 lines
454 B
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
:- module singleton_test_state_var.
:- interface.
:- import_module list.
:- pred foo(int::in, int::in, list(int)::in, int::out) is det.
:- implementation.
foo(A, B, !.State, X) :-
( if !.State = [A | !:State] then
X = B
else
X = A
).