[m-dev.] for review: fix specialization of higher-order unification

Simon Taylor stayl at cs.mu.OZ.AU
Mon Sep 20 14:03:31 AEST 1999


Estimated hours taken: 0.5

compiler/higher_order.m:
	Fix a compiler abort caused by higher_order.m not removing
	the type-info arguments when specializing a call to unify/2,
	index/2 or compare/3 into a call to builtin_*_pred. 
	
tests/valid/Mmakefile:
tests/valid/ho_unify.m:
	Test case.


Index: compiler/higher_order.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/higher_order.m,v
retrieving revision 1.54
diff -u -u -r1.54 higher_order.m
--- higher_order.m	1999/08/13 01:42:59	1.54
+++ higher_order.m	1999/09/20 03:49:22
@@ -1556,7 +1556,13 @@
 	;
 		polymorphism__get_special_proc(SpecialPredType, SpecialId,
 			ModuleInfo, SymName, SpecialPredId, SpecialProcId),
-		list__append(TypeInfoArgs, SpecialPredArgs, CallArgs),
+		( type_is_higher_order(SpecialPredType, _, _, _) ->
+			% builtin_*_pred are special cases which
+			% doesn't need the type-info arguments.
+			CallArgs = SpecialPredArgs
+		;
+			list__append(TypeInfoArgs, SpecialPredArgs, CallArgs)
+		),	
 		Goal = call(SpecialPredId, SpecialProcId, CallArgs,
 			not_builtin, MaybeContext, SymName)
 	).
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/tests/valid/Mmakefile,v
retrieving revision 1.41
diff -u -u -r1.41 Mmakefile
--- Mmakefile	1999/08/31 05:26:06	1.41
+++ Mmakefile	1999/09/20 03:58:15
@@ -52,6 +52,7 @@
 	higher_order_implied_mode.m \
 	ho_func_call.m \
 	ho_inst.m \
+	ho_unify.m \
 	implied_mode.m \
 	indexing.m \
 	inhibit_warn_test.m \

tests/valid/ho_unify.m
===================================================================
% The compiler of 20/9/1999 aborted on this test case
% due to higher_order.m erroneously adding type-info arguments
% when specializing the call to unify/2 into a call to
% builtin_unify_pred/2.
:- module ho_unify.

:- interface.

:- pred ho_unify(pred(int), pred(int)). 
:- mode ho_unify(pred(in) is semidet, pred(in) is semidet) is semidet.

:- implementation.

ho_unify(X, Y) :-
	unify(X, Y).
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list