cvs diff: bugfix: outputting 0 arity pred/func insts to `.int' files

David Matthew OVERTON dmo at students.cs.mu.oz.au
Fri Sep 5 21:10:54 AEST 1997


Hi Fergus,

Could you please review this diff.  Note that this change is to the
main CVS branch, not the alias branch.

David.
--
      David Overton              |  4th Year Software Engineering
 dmo at students.cs.mu.oz.au        |  Department of Computer Science
http://www.cs.mu.oz.au/~dmo/     |  The University of Melbourne
===================================================================

Estimated hours taken: 1.5

Fix a couple of bugs with outputting 0 arity pred and func insts.

compiler/mercury_to_mercury.m:
        Predicate `mercury_output_inst' was incorrectly outputting
	code to the `.int' file for 
		:- inst foo = ((func) = out is Det).
	and
		:- inst bar = ((pred) is Det).
	The incorrect `.int' file generated a syntax error when read
	back in by the compiler.

Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.115
diff -u -r1.115 mercury_to_mercury.m
--- 1.115	1997/09/01 04:18:15
+++ mercury_to_mercury.m	1997/09/05 10:20:18
@@ -505,8 +505,9 @@
 		(
 			{ PredOrFunc = predicate },
 			( { Modes = [] } ->
-				io__write_string("(pred) is "),
-				mercury_output_det(Det)
+				io__write_string("((pred) is "),
+				mercury_output_det(Det),
+				io__write_string(")")
 			;
 				io__write_string("(pred("),
 				mercury_output_mode_list(Modes, VarSet),
@@ -517,9 +518,14 @@
 		;
 			{ PredOrFunc = function },
 			{ pred_args_to_func_args(Modes, ArgModes, RetMode) },
-			io__write_string("(func("),
-			mercury_output_mode_list(ArgModes, VarSet),
-			io__write_string(") = "),
+			( { ArgModes = [] } ->
+				io__write_string("((func)")
+			;
+				io__write_string("(func("),
+				mercury_output_mode_list(ArgModes, VarSet),
+				io__write_string(")")
+			),
+			io__write_string(" = "),
 			mercury_output_mode(RetMode, VarSet),
 			io__write_string(" is "),
 			mercury_output_det(Det),



More information about the developers mailing list