[m-rev.] diff: fix typechecker abort

Simon Taylor stayl at cs.mu.OZ.AU
Sat Feb 22 12:05:49 AEDT 2003


Estimated hours taken: 1
Branches: main, release

compiler/typecheck.m:
	Fix a bug which caused an abort on unifications of the form
	`X = X', where `X' hadn't been seen before in the goal.

tests/valid/Mmakefile:
tests/valid/id_type_bug.m:
	Test case.	

Index: compiler/typecheck.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.328
diff -u -u -r1.328 typecheck.m
--- compiler/typecheck.m	21 Feb 2003 01:54:40 -0000	1.328
+++ compiler/typecheck.m	21 Feb 2003 15:14:09 -0000
@@ -2746,7 +2746,11 @@
 				TypeAssign1),
 			Type = term__variable(TypeVar),
 			map__det_insert(VarTypes0, X, Type, VarTypes1),
-			map__det_insert(VarTypes1, Y, Type, VarTypes),
+			( X \= Y ->
+				map__det_insert(VarTypes1, Y, Type, VarTypes)
+			;
+				VarTypes = VarTypes1
+			),
 			type_assign_set_var_types(TypeAssign1, VarTypes,
 				TypeAssign),
 			TypeAssignSet = [TypeAssign | TypeAssignSet0]
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.124
diff -u -u -r1.124 Mmakefile
--- tests/valid/Mmakefile	17 Feb 2003 06:07:15 -0000	1.124
+++ tests/valid/Mmakefile	21 Feb 2003 14:27:27 -0000
@@ -87,6 +87,7 @@
 	ho_func_call \
 	ho_inst \
 	ho_unify \
+	id_type_bug \
 	implied_mode \
 	indexing \
 	inhibit_warn_test \
Index: tests/valid/id_type_bug.m
===================================================================
RCS file: tests/valid/id_type_bug.m
diff -N tests/valid/id_type_bug.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/id_type_bug.m	21 Feb 2003 15:12:01 -0000
@@ -0,0 +1,28 @@
+% A regression test for a compiler abort on unifications
+% of the form `X = X'.
+:- module id_type_bug.
+
+:- interface.
+
+:- pred p(int::in, int::out) is det.
+
+%------------------------------------------------------------------------------%
+%------------------------------------------------------------------------------%
+
+:- implementation.
+
+p(A, B) :-
+	( q(A, X0), Z = Z ->
+		X = X0
+	;
+		X = 1
+	),
+    p(X, B).
+
+:- pred q(int::in, int::out) is semidet.
+
+q(1, 5).
+
+
+%------------------------------------------------------------------------------%
+%------------------------------------------------------------------------------%
--------------------------------------------------------------------------
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