[m-dev.] diff: fix unique_modes error message

Simon Taylor stayl at cs.mu.OZ.AU
Wed Jul 14 17:17:15 AEST 1999


Estimated hours taken: 0.25

compiler/unique_modes.m:
	The argument offset for higher-order calls was being set
	to 0, not 1 (the higher-order term is not included in
	the argument list). This resulted in the argument numbers
	in error messages for higher-order calls being one less
	than expected.

tests/invalid/Mmakefile:
tests/invalid/ho_unique_error.m:
tests/invalid/ho_unique_error.err_exp:
	Test case.

Index: compiler/unique_modes.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/unique_modes.m,v
retrieving revision 1.54
diff -u -u -r1.54 unique_modes.m
--- unique_modes.m	1999/07/13 08:53:40	1.54
+++ unique_modes.m	1999/07/14 02:44:53
@@ -398,13 +398,24 @@
 	},
 	{ determinism_to_code_model(Det, CodeModel) },
 
-	% `aditi_insert' goals have type_info arguments for each
-	% of the arguments of the tuple to insert added to the
-	% start of the argument list by polymorphism.m.
-	{ GenericCall = aditi_builtin(aditi_insert(_), _ - _/Arity) ->
-		ArgOffset = -Arity
+	{
+		GenericCall = higher_order(_, _, _),
+		ArgOffset = 1
 	;
+		% Class method calls are introduced by the compiler
+		% and should be mode correct.
+		GenericCall = class_method(_, _, _, _),
 		ArgOffset = 0
+	;
+		% `aditi_insert' goals have type_info arguments for each
+		% of the arguments of the tuple to insert added to the
+		% start of the argument list by polymorphism.m.
+		GenericCall = aditi_builtin(Builtin, UpdatedCallId),
+		( Builtin = aditi_insert(_), UpdatedCallId = _ - _/Arity ->
+			ArgOffset = -Arity
+		;
+			ArgOffset = 0
+		)
 	},
 
 	unique_modes__check_call_modes(Args, Modes, ArgOffset,
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/tests/invalid/Mmakefile,v
retrieving revision 1.43
diff -u -u -r1.43 Mmakefile
--- Mmakefile	1999/07/13 08:55:05	1.43
+++ Mmakefile	1999/07/14 06:43:00
@@ -24,6 +24,7 @@
 	func_errors.m \
 	funcs_as_preds.m \
 	ho_type_mode_bug.m \
+	ho_unique_error.m \
 	inline_conflict.m \
 	io_in_ite_cond.m \
 	missing_det_decls.m \


Index: tests/invalid/ho_unique_error.m
===================================================================
:- module ho_unique_error.

:- interface.

:- import_module io.

:- pred call_ho(io__state::di, io__state::uo) is multi.

:- implementation.

call_ho -->
	( call(io__write_string, "First\n")
	; call(io__write_string, "Second\n")
	).

Index: tests/invalid/ho_unique_error.err_exp
===================================================================
ho_unique_error.m:012: In clause for `call_ho(di, uo)':
ho_unique_error.m:012:   in argument 3 (i.e. argument 2 of the called predicate) of higher-order predicate call:
ho_unique_error.m:012:   mode error: variable `DCG_0' has instantiatedness `mostly_unique',
ho_unique_error.m:012:   expected instantiatedness was `unique'.
For more information, try recompiling with `-E'.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list