[m-rev.] for review: fix mode analysis bugs

David Overton dmo at cs.mu.OZ.AU
Mon Aug 12 14:16:59 AEST 2002


Hi,

This change fixes a bug reported by Tom Schrijvers.  It is currently
bootchecking.


David


Estimated hours taken: 3
Branches: main

Fix a couple of bugs related to abstract unification.

compiler/inst_util.m:
	Add cases to `make_ground_inst' and `make_any_inst' to handle
	`constrained_inst_vars'.

	When `make_ground_inst' is called with a higher-order inst, do not
	discard the higher-order information from the resulting inst
	(`make_any_inst' already handles this correctly).

tests/valid/Mmakefile:
tests/valid/constrained_poly_bound_arg.m:
	Add the test case from Fergus's bug report.

Index: compiler/inst_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/inst_util.m,v
retrieving revision 1.23
diff -u -r1.23 inst_util.m
--- compiler/inst_util.m	30 Jul 2002 04:29:42 -0000	1.23
+++ compiler/inst_util.m	12 Aug 2002 03:56:11 -0000
@@ -875,11 +875,15 @@
 	make_ground_bound_inst_list(BoundInsts0, IsLive, Uniq1, Real, M0,
 					BoundInsts, Det1, M),
 	det_par_conjunction_detism(Det1, semidet, Det).
-make_ground_inst(ground(Uniq0, _GII0), IsLive, Uniq1, Real, M,
-		ground(Uniq, none), semidet, M) :-
+make_ground_inst(ground(Uniq0, GroundInstInfo), IsLive, Uniq1, Real, M,
+		ground(Uniq, GroundInstInfo), semidet, M) :-
 	unify_uniq(IsLive, Real, semidet, Uniq0, Uniq1, Uniq).
 make_ground_inst(inst_var(_), _, _, _, _, _, _, _) :-
 	error("free inst var").
+make_ground_inst(constrained_inst_vars(InstVars, InstConstraint), IsLive,
+		Uniq, Real, M0, Inst, Det, M) :-
+	abstractly_unify_constrained_inst_vars(IsLive, InstVars,
+		InstConstraint, ground(Uniq, none), Real, M0, Inst, Det, M).
 make_ground_inst(abstract_inst(_,_), _, _, _, M, ground(shared, none),
 		semidet, M).
 make_ground_inst(defined_inst(InstName), IsLive, Uniq, Real, ModuleInfo0,
@@ -990,6 +994,10 @@
 	unify_uniq(IsLive, Real, semidet, Uniq0, Uniq1, Uniq).
 make_any_inst(inst_var(_), _, _, _, _, _, _, _) :-
 	error("free inst var").
+make_any_inst(constrained_inst_vars(InstVars, InstConstraint), IsLive,
+		Uniq, Real, M0, Inst, Det, M) :-
+	abstractly_unify_constrained_inst_vars(IsLive, InstVars,
+		InstConstraint, any(Uniq), Real, M0, Inst, Det, M).
 make_any_inst(abstract_inst(_,_), _, _, _, M, any(shared),
 		semidet, M).
 make_any_inst(defined_inst(InstName), IsLive, Uniq, Real, ModuleInfo0,
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.110
diff -u -r1.110 Mmakefile
--- tests/valid/Mmakefile	29 Jul 2002 16:28:31 -0000	1.110
+++ tests/valid/Mmakefile	12 Aug 2002 04:01:31 -0000
@@ -55,6 +55,7 @@
 	common_struct_bug.m \
 	compl_unify_bug.m \
 	complicated_unify.m \
+	constrained_poly_bound_arg.m \
 	constrained_poly_insts.m \
 	constructor_arg_names.m \
 	dcg_test.m \
Index: tests/valid/constrained_poly_bound_arg.m
===================================================================
RCS file: tests/valid/constrained_poly_bound_arg.m
diff -N tests/valid/constrained_poly_bound_arg.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/constrained_poly_bound_arg.m	12 Aug 2002 04:00:35 -0000
@@ -0,0 +1,29 @@
+:- module constrained_poly_bound_arg.
+
+:- interface.
+
+:- type val_closure(X1)
+        ---> val_closure(pred(X1)).
+
+:- type closure_list(X2)
+        ---> nil
+	;    list(X2,val_closure(closure_list(X2))).
+
+:- inst val_closure(X3)
+        == bound( error3__val_closure(pred(out(X3)) is det) ).
+
+:- inst closure_list(X4)
+        == bound( error3__nil
+ 	        ; error3__list(X4,val_closure(closure_list(X4)))
+ 		).
+:- implementation.
+
+:- pred eval(X5,X5).
+:- mode eval(in(X6 =< ground),out(X6 =< ground)) is det.
+eval(X,X).
+
+:- pred m(closure_list(X8), closure_list(X8)).
+:- mode m(in(closure_list(X9 =< ground)), out(closure_list(X9 =< ground)))
+	is det.
+m(CCL,RCL) :-
+  eval(CCL,RCL).

-- 
David Overton                  Uni of Melbourne     +61 3 8344 9159
dmo at cs.mu.oz.au                Monash Uni (Clayton) +61 3 9905 5779
http://www.cs.mu.oz.au/~dmo    Mobile Phone         +61 4 0337 4393
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list