mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-20 03:43:51 +00:00
where switch detection was getting confused by explicit existential quantifications. compiler/switch_detection.m: When detecting switches, traverse through some/2 goals. Also simplify the code a bit. tests/valid/Mmakefile: tests/valid/some_switch.m: Regression test for the above change.
19 lines
402 B
Mathematica
19 lines
402 B
Mathematica
% Test of switch detection with explicit existential quantification.
|
|
|
|
:- module some_switch.
|
|
:- interface.
|
|
|
|
:- type nat ---> o ; s(nat).
|
|
|
|
:- func add(nat,nat) = nat.
|
|
:- mode add(in,in) = in is semidet.
|
|
:- mode add(out,out) = in is multi.
|
|
:- mode add(in,in) = out is det.
|
|
|
|
:- implementation.
|
|
|
|
add(X,Y) = Z :-
|
|
( ( X=o , Z=Y ) ;
|
|
some [Xp] ( X=s(Xp), Z=s(add(Xp,Y)) ) ).
|
|
|