diff: simplify.m bug
Simon TAYLOR
stayl at students.cs.mu.oz.au
Wed Jun 25 17:57:39 AEST 1997
Hi Fergus,
Could you please review this.
Simon.
Estimated hours taken: 0.5
compiler/simplify.m
Fix a bug in simplify.m where deconstructions were being
propagated into lambda expressions, but the non-locals of the
lambda expressions were not being updated.
tests/valid/lambda_struct_bug.m
Regression test.
Index: simplify.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/simplify.m,v
retrieving revision 1.33
diff -u -r1.33 simplify.m
--- simplify.m 1997/05/21 02:13:49 1.33
+++ simplify.m 1997/06/21 13:17:00
@@ -439,15 +439,23 @@
RT0 = lambda_goal(PredOrFunc, Vars, Modes, LambdaDeclaredDet,
LambdaGoal0)
->
- simplify_info_get_common_info(Info0, Common),
+ simplify_info_get_common_info(Info0, Common0),
simplify_info_get_module_info(Info0, ModuleInfo),
simplify_info_get_instmap(Info0, InstMap0),
instmap__pre_lambda_update(ModuleInfo, Vars, Modes,
InstMap0, InstMap1),
simplify_info_set_instmap(Info0, InstMap1, Info1),
- simplify__goal(LambdaGoal0, LambdaGoal, Info1, Info2),
- simplify_info_set_common_info(Info2, Common, Info3),
- simplify_info_set_instmap(Info3, InstMap0, Info),
+
+ % Don't attempt to pass structs into lambda_goals,
+ % since that could change the curried non-locals of the
+ % lambda_goal, and that would be difficult to fix up.
+ common_info_init(Common1),
+ simplify_info_set_common_info(Info1, Common1, Info2),
+
+ % Don't attempt to pass structs out of lambda_goals.
+ simplify__goal(LambdaGoal0, LambdaGoal, Info2, Info3),
+ simplify_info_set_common_info(Info3, Common0, Info4),
+ simplify_info_set_instmap(Info4, InstMap0, Info),
RT = lambda_goal(PredOrFunc, Vars, Modes, LambdaDeclaredDet,
LambdaGoal),
Goal = unify(LT0, RT, M, U0, C),
Index: Mmake
===================================================================
RCS file: /home/staff/zs/imp/tests/valid/Mmake,v
retrieving revision 1.39
diff -u -r1.39 Mmake
--- Mmake 1997/06/03 06:23:07 1.39
+++ Mmake 1997/06/25 07:53:46
@@ -34,6 +34,7 @@
lambda_inference.m\
lambda_instmap_bug.m \
lambda_quant.m \
+ lambda_struct_bug.m \
lambda_switch.m \
lambda_type.m \
loop.m \
% This is a regression test for a bug in simplify/common.m where
% the pos(X, Y) deconstruction in the head of adj/4 was being propagated
% into the body of the lambda expression, but the non-locals of
% the lambda expression were not being updated.
:- module lambda_struct_bug.
:- interface.
:- import_module list, std_util, set.
:- type pos
---> pos(int, int).
:- type adj
---> adj(pos, pos).
:- type maze == set(pair(pos, pos)).
:- pred adj(pos, list(adj)).
:- mode adj(in, out) is det.
:- implementation.
:- import_module int, require.
adj(pos(X, Y), Adjs) :-
Pred = lambda([Adj::out] is nondet, (
(
X1 is X - 1,
Adj = adj(pos(X1, Y), pos(X, Y))
;
X1 is X + 1,
Adj = adj(pos(X1, Y), pos(X, Y))
;
Y1 is Y + 1,
Adj = adj(pos(X, Y1), pos(X, Y))
;
Y1 is Y - 1,
Adj = adj(pos(X, Y1), pos(X, Y))
),
Adj = adj(pos(A, B), _),
A >= 0, A =< 10, % XXX
B >= 0, B =< 10 % XXX
)),
solutions(Pred, Adjs).
More information about the developers
mailing list