Files
mercury/tests/valid/some_singleton.m
Zoltan Somogyi 06542c7070 Add a test case for singleton warnings we don't yet pass.
tests/valid/some_singleton.m:
    The new test case.

tests/valid/Mercury.options:
    Specify the options for the test case.

tests/valid/Mmakefile:
    List the test case, but do not enable it yet.
2019-05-28 23:05:20 +02:00

35 lines
714 B
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% A test whether the compiler detects that a variable that occurs only
%
% - once in a scope, and
% - and in the list of variables quantified by that scope
%
% is NOT a singleton.
:- module some_singleton.
:- interface.
:- pred p(int::in, int::out) is det.
:- implementation.
p(A, C) :-
( if
some [B] (
q(A, B) % B should NOT be reported as a singleton.
)
then
C = 100
else
C = 200
).
:- pred q(int::in, int::out) is nondet.
q(1, 11).
q(1, 12).
q(2, 21).