[m-rev.] diff: fix output of zero arity pred terms

Simon Taylor stayl at cs.mu.OZ.AU
Sun Aug 12 18:18:39 AEST 2001


Estimated hours taken: 0.25
Branches: main, release

compiler/hlds_out.m:
	Write zero arity predicate terms as `((pred) is semidet :- Goal)'
	rather than `(pred() is semidet :- Goal)'.'

tests/valid/intermod_lambda2.m:
	Test case.

Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.267
retrieving revision 1.268
diff -u -u -r1.267 -r1.268
--- compiler/hlds_out.m	2001/08/03 08:26:55	1.267
+++ compiler/hlds_out.m	2001/08/12 08:16:24	1.268
@@ -1981,10 +1981,15 @@
 		{ PredOrFunc = predicate },
 		io__write_string("("),
 		io__write_string(EvalStr),
-		io__write_string("pred("),
-		hlds_out__write_var_modes(Vars, Modes, VarSet, InstVarSet,
-			AppendVarnums),
-		io__write_string(") is "),
+		( { Vars = [] } ->
+			io__write_string("(pred)")
+		;
+			io__write_string("pred("),
+			hlds_out__write_var_modes(Vars, Modes, VarSet,
+				InstVarSet, AppendVarnums),
+			io__write_string(")")
+		),
+		io__write_string(" is "),
 		mercury_output_det(Det),
 		io__write_string(" :-\n"),
 		hlds_out__write_goal_a(Goal, ModuleInfo, VarSet, AppendVarnums,
@@ -1997,10 +2002,15 @@
 		{ pred_args_to_func_args(Vars, ArgVars, RetVar) },
 		io__write_string("("),
 		io__write_string(EvalStr),
-		io__write_string("func("),
-		hlds_out__write_var_modes(ArgVars, ArgModes, VarSet,
-			InstVarSet, AppendVarnums),
-		io__write_string(") = ("),
+		( { ArgVars = [] } ->
+			io__write_string("(func)")
+		;
+			io__write_string("func("),
+			hlds_out__write_var_modes(ArgVars, ArgModes, VarSet,
+				InstVarSet, AppendVarnums),
+			io__write_string(")")
+		),
+		io__write_string(" = ("),
 		hlds_out__write_var_mode(RetVar, RetMode, VarSet,
 			InstVarSet, AppendVarnums),
 		io__write_string(") is "),
Index: tests/valid/intermod_lambda2.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/intermod_lambda2.m,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -u -r1.3 -r1.4
--- tests/valid/intermod_lambda2.m	1998/02/04 12:10:41	1.3
+++ tests/valid/intermod_lambda2.m	2001/08/12 08:16:31	1.4
@@ -18,17 +18,20 @@
 :- mode in2 :: in.
 
 sol(Generator, List) :-
+	Test = ((pred) is semidet),
+	TestFunc = ((func) = 1),
 	Cons = lambda([Elem::in, L0::in, L::out] is det, (
 			cons(Elem, L0, L)
 		)),
-	t(Generator, Cons, [], List).
+	t(Test, TestFunc, Generator, Cons, [], List).
 
 :- pred cons(T::in, list(T)::in, list(T)::out) is det.
 cons(H, T, [H|T]).
 
-:- pred t(pred(T), pred(T,T2,T2), T2, T2).
-:- mode t(pred(out) is det, pred(in,in,out) is det, in2, out) is det.
+:- pred t((pred), ((func) = int), pred(T), pred(T,T2,T2), T2, T2).
+:- mode t((pred) is semidet, ((func) = out is det),
+		pred(out) is det, pred(in,in,out) is det, in2, out) is det.
 
-t(_, _, A, A).
+t(_, _, _, _, A, A).
 
 %-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
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