diff: bug fix for list__merge_and_remove_dups/4

Tyson Dowd trd at cs.mu.OZ.AU
Tue Sep 15 17:36:28 AEST 1998


Hi,

This is a fairly simple fix.  Anyone can review it.

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


Estimated hours taken: 1

Fix a bug reported by Peter Herkenrath <aik01 at rrz.uni-koeln.de>.

library/list.m:
	Make list__merge_and_remove_dups/4 recursively call itself,
	not list__merge.

tests/general/Mmakefile:
tests/general/merge_and_remove_dups.exp:
tests/general/merge_and_remove_dups.m:
	A regression test for this bug.	


Index: library/list.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/list.m,v
retrieving revision 1.84
diff -u -r1.84 list.m
--- list.m	1998/07/27 01:05:09	1.84
+++ list.m	1998/09/14 05:25:04
@@ -1118,15 +1118,15 @@
 	(
 		C = (<),
 		L = [H1|T],   
-		list__merge(P, T1, [H2|T2], T)
+		list__merge_and_remove_dups(P, T1, [H2|T2], T)
 	;
 		C = (=),
 		L = [H1 | T],
-		list__merge(P, T1, T2, T)
+		list__merge_and_remove_dups(P, T1, T2, T)
 	;
 		C = (>),
 		L = [H2|T],   
-		list__merge(P, [H1|T1], T2, T)
+		list__merge_and_remove_dups(P, [H1|T1], T2, T)
 	).
 
 
Index: tests/general/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/general/Mmakefile,v
retrieving revision 1.21
diff -u -r1.21 Mmakefile
--- Mmakefile	1998/09/09 06:05:24	1.21
+++ Mmakefile	1998/09/15 06:58:08
@@ -37,6 +37,7 @@
 		interpreter \
 		liveness \
 		liveness2 \
+		merge_and_remove_dups \
 		mode_inf \
 		mode_inf_bug \
 		mu \
Index: tests/general/merge_and_remove_dups.exp
===================================================================
RCS file: merge_and_remove_dups.exp
diff -N merge_and_remove_dups.exp
--- /dev/null	Wed May 28 10:49:58 1997
+++ merge_and_remove_dups.exp	Tue Sep 15 16:58:55 1998
@@ -0,0 +1,3 @@
+List1: [1, 2, 3]
+List2: [3, 4, 5]
+List3: [1, 2, 3, 4, 5]
Index: tests/general/merge_and_remove_dups.m
===================================================================
RCS file: merge_and_remove_dups.m
diff -N merge_and_remove_dups.m
--- /dev/null	Wed May 28 10:49:58 1997
+++ merge_and_remove_dups.m	Tue Sep 15 16:57:17 1998
@@ -0,0 +1,39 @@
+%
+% A regression test.  Make sure list__merge_and_remove_dups works.
+%
+% The Mercury library of September 15th, 1998 failed this test.
+%
+% Peter Herkenrath <aik01 at rrz.uni-koeln.de> sent this one in.
+
+:- module merge_and_remove_dups.
+
+:- interface.
+
+:- pred main(io:state::di, io:state::uo) is det.
+
+:- implementation.
+
+:- import_module list, io.
+
+main -->
+        { List1 = [1,2,3],
+          List2 = [3,4,5],
+          P = lambda([I1::in,I2::in,R::out] is det,
+                         (compare(R,I1,I2)) ),
+          list__merge_and_remove_dups(P,List1,List2,List3) },
+        io__write_string("List1: "),
+        io__print(List1),
+        io__write_string("\nList2: "),
+        io__print(List2),
+        io__write_string("\nList3: "),
+        io__print(List3),
+        io__write_string("\n").
+
+%Output:
+%List1: [1, 2, 3]
+%List2: [3, 4, 5]
+%List3: [1, 2, 3, 3, 4, 5]
+%              !  !
+
+
+


-- 
       Tyson Dowd           # There isn't any reason why Linux can't be
                            # implemented as an enterprise computing solution.
     trd at cs.mu.oz.au        # Find out what you've been missing while you've
http://www.cs.mu.oz.au/~trd # been rebooting Windows NT. -- InfoWorld, 1998.



More information about the developers mailing list