[m-rev.] [reuse] bugfix: empty branchlist

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Fri Jul 6 19:44:43 AEST 2001


===================================================================

Estimated hours taken: 0.2
Branches: reuse

Disjunctions can have an empty list of branches, 
so don't produce an error message in such cases. 

sr_choice_graphing.m:
	Catch the situations with an empty list of branches apropriately. 


Index: sr_choice_graphing.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_choice_graphing.m,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 sr_choice_graphing.m
--- sr_choice_graphing.m	2001/07/05 15:33:31	1.1.2.1
+++ sr_choice_graphing.m	2001/07/06 09:32:45
@@ -457,14 +457,20 @@
 		value::in, value::out) is det.
 disjunction_value_of_dead_cel(Background, Deconstruction, 
 		Branches, Val0, Val):- 
-	list__map(
-		pred(G::in, V::out) is det:- 
-		    ( value_of_dead_cel_in_goal(Background, 
-			Deconstruction, G, Val0, V)), 
-		Branches, BranchVals), 
-	count_candidates(BranchVals, Degree), 
-	average_value(BranchVals, Val1),
-	Val = Val1 ^ degree := Degree.
+	(
+		Branches = []
+	-> 	
+		Val = Val0
+	; 
+		list__map(
+			pred(G::in, V::out) is det:- 
+			    ( value_of_dead_cel_in_goal(Background, 
+				Deconstruction, G, Val0, V)), 
+			Branches, BranchVals), 
+		count_candidates(BranchVals, Degree), 
+		average_value(BranchVals, Val1),
+		Val = Val1 ^ degree := Degree
+	).
 
 :- pred count_candidates(list(value)::in, int::out) is det.
 count_candidates(Values, Degree):- 

--------------------------------------------------------------------------
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