mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 13:55:07 +00:00
for variables in lambda goals. compiler/quantification.m: (1) When implicitly-quantifying a lambda goal, the "lambda-outsidevars" should be set to the empty set, so that variables occurring only inside disjoint lambda goals are locally quantified inside those lambda goals. (2) When quantifying conjunctions and if-then-elses, use both the lambda outsidevars and the ordinary outsidevars when computing the non-locals, rather than just using the ordinary outsidevars. tests/valid/lambda_quant.m: Add another test case for bug (1). There was already a tests in this module that was supposed to test this sort of stuff, but that test case happened to work, because the effects of bugs (1) and (2) cancelled out. :-( tests/valid/Mmake: tests/valid/lambda_quant_bug.m: Add a regression test for bug (2).
60 lines
1.6 KiB
Mathematica
60 lines
1.6 KiB
Mathematica
/*
|
|
|
|
Regression test: a bug in quantification caused a software abort with the
|
|
message "assoc_list__from_corresponding_lists: different lengths".
|
|
|
|
A cursory examination showed that the compiler thought that "Proj"
|
|
was local to the switch on "MProj" after the first simplification
|
|
pass.
|
|
*/
|
|
|
|
:- module lambda_quant_bug.
|
|
:- interface.
|
|
:- import_module io, bool.
|
|
|
|
:- type cl_result ---> ok(int) ; error(int).
|
|
|
|
:- pred all_reports(bool, cl_result, io__state, io__state).
|
|
:- mode all_reports(in, out, di, uo) is det.
|
|
|
|
%------------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int, string, list.
|
|
|
|
all_reports(MProj, MTuples) -->
|
|
{ get_structure(MTemp) },
|
|
(
|
|
{ MTemp = ok(_) },
|
|
(
|
|
{ MProj = yes },
|
|
{ list__map(find, [], Proj) }
|
|
;
|
|
{ MProj = no },
|
|
{ list__map(find, [], Proj) }
|
|
),
|
|
list__map_foldl(adjust_tuple(Proj), [], _),
|
|
{ MTuples = ok(42) }
|
|
;
|
|
{ MTemp = error(Err) },
|
|
{ MTuples = error(Err) }
|
|
).
|
|
|
|
:- pragma no_inline(adjust_tuple/5).
|
|
:- pred adjust_tuple(list(int), int, int, io__state, io__state).
|
|
:- mode adjust_tuple(in, in, out, di, uo) is det.
|
|
|
|
adjust_tuple(_, _, 42) --> [].
|
|
|
|
:- pragma no_inline(get_structure/1).
|
|
:- pred get_structure(cl_result :: out) is det.
|
|
|
|
get_structure(error(42)).
|
|
|
|
:- pragma no_inline(find/2).
|
|
:- pred find(int, int).
|
|
:- mode find(in, out) is det.
|
|
|
|
find(_, 42).
|