mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
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.
35 lines
714 B
Mathematica
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).
|