diff: improve impurity error messages

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Feb 15 01:44:21 AEDT 1998


Estimated hours taken: 1

compiler/modes.m:
	When reporting impurity errors, report all such errors;
	the previous code tried to report only the first one,
	but due to a bug only reported the *last* one, which 
	I found quite confusing.

cvs diff  compiler/modes.m
Index: compiler/modes.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modes.m,v
retrieving revision 1.219
diff -u -r1.219 modes.m
--- modes.m	1998/02/12 01:17:37	1.219
+++ modes.m	1998/02/14 14:31:41
@@ -1129,7 +1129,7 @@
 	mode_info_set_delay_info(DelayInfo1),
 	mode_info_add_goals_live_vars(Goals0),
 
-	modecheck_conj_list_2(Goals0, [], Goals, ImpurityErrors),
+	modecheck_conj_list_2(Goals0, [], Goals, RevImpurityErrors),
 
 	=(ModeInfo3),
 	{ mode_info_get_errors(ModeInfo3, NewErrors) },
@@ -1150,13 +1150,15 @@
 	),
 	% we only report impurity errors if there were no other errors
 	( { DelayedGoals = [] } ->
-		% XXX perhaps we should report all the impurity errors,
-		% rather than just the first one
-		( { ImpurityErrors = [FirstImpurityError | _Rest] } ->
-			mode_info_add_error(FirstImpurityError)
-	      	;
-			[]
-	      	)	       
+		%
+		% report all the impurity errors
+		% (making sure we report the errors in the correct order)
+		%
+		{ list__reverse(RevImpurityErrors, ImpurityErrors) },
+		=(ModeInfo4),
+		{ mode_info_get_errors(ModeInfo4, Errors4) },
+		{ list__append(Errors4, ImpurityErrors, Errors5) },
+		mode_info_set_errors(Errors5)
 	; { DelayedGoals = [delayed_goal(_DVars, Error, _DGoal)] } ->
 		mode_info_add_error(Error)
 	;

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list