diff: fix incorrect argument numbers in mode error messages

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Aug 3 23:03:41 AEST 1998


The following fixes a bug reported by Bart Demoen.
(I should add a test case before committing this.)

--------------------

Fix a couple of bugs that resulted in error messages containing
incorrect argument numbers.

compiler/modes.m:
	Change modecheck_set_var_inst_list to set the argument number,
	so that error messages reported by handle_implied_mode
	report the correct argument number.

compiler/modecheck_call.m:
	Fix an off-by-one error: the initial value of the argument
	counter in modecheck_var_has_inst_inst should be 0, not 1.

Index: compiler/modecheck_call.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modecheck_call.m,v
retrieving revision 1.25
diff -u -r1.25 modecheck_call.m
--- modecheck_call.m	1998/05/30 15:22:40	1.25
+++ modecheck_call.m	1998/08/03 12:48:31
@@ -155,7 +155,7 @@
 		% extra unifications for implied modes, if necessary).
 		%
 		mode_list_get_initial_insts(Modes, ModuleInfo0, InitialInsts),
-		modecheck_var_has_inst_list(Args0, InitialInsts, 1,
+		modecheck_var_has_inst_list(Args0, InitialInsts, 0,
 					ModeInfo1, ModeInfo2),
 		mode_list_get_final_insts(Modes, ModuleInfo0, FinalInsts),
 		modecheck_set_var_inst_list(Args0, InitialInsts, FinalInsts,
Index: compiler/modes.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modes.m,v
retrieving revision 1.225
diff -u -r1.225 modes.m
--- modes.m	1998/06/09 02:14:02	1.225
+++ modes.m	1998/08/03 13:01:29
@@ -1551,7 +1551,7 @@
 modecheck_set_var_inst_list(Vars0, InitialInsts, FinalInsts, Vars, Goals) -->
 	(
 		modecheck_set_var_inst_list_2(Vars0, InitialInsts, FinalInsts,
-			no_extra_goals, Vars1, Goals1)
+			no_extra_goals, 0, Vars1, Goals1)
 	->
 		{ Vars = Vars1, Goals = Goals1 }
 	;
@@ -1559,19 +1559,23 @@
 	).
 
 :- pred modecheck_set_var_inst_list_2(list(var), list(inst), list(inst),
-					extra_goals, list(var), extra_goals,
+					extra_goals, int,
+					list(var), extra_goals,
 					mode_info, mode_info).
-:- mode modecheck_set_var_inst_list_2(in, in, in, in, out, out,
+:- mode modecheck_set_var_inst_list_2(in, in, in, in, in, out, out,
 					mode_info_di, mode_info_uo) is semidet.
 
-modecheck_set_var_inst_list_2([], [], [], ExtraGoals, [], ExtraGoals) --> [].
+modecheck_set_var_inst_list_2([], [], [], ExtraGoals, _, [], ExtraGoals) -->
+	[].
 modecheck_set_var_inst_list_2([Var0 | Vars0], [InitialInst | InitialInsts],
-			[FinalInst | FinalInsts], ExtraGoals0,
+			[FinalInst | FinalInsts], ExtraGoals0, ArgNum0,
 			[Var | Vars], ExtraGoals) -->
+	{ ArgNum is ArgNum0 + 1 },
+	mode_info_set_call_arg_context(ArgNum),
 	modecheck_set_var_inst(Var0, InitialInst, FinalInst,
 				Var, ExtraGoals0, ExtraGoals1),
 	modecheck_set_var_inst_list_2(Vars0, InitialInsts, FinalInsts,
- 				ExtraGoals1, Vars, ExtraGoals).
+ 				ExtraGoals1, ArgNum, Vars, ExtraGoals).
 
 :- pred modecheck_set_var_inst(var, inst, inst, var, extra_goals, extra_goals,
 				mode_info, mode_info).

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