[m-rev.] diff: better mode error messages

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Apr 25 18:33:45 AEST 2005


compiler/mode_errors.m:
	When printing error messages involving lists of insts, put each inst
	on a line of its own. Since insts can be deeply nested, it could be
	difficult to divide the generated humongous lines into the original
	sequence of insts without this diff.

tests/invalid/*.err_exp:
	Expect the new format of error messages.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/mode_errors.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_errors.m,v
retrieving revision 1.85
diff -u -b -r1.85 mode_errors.m
--- compiler/mode_errors.m	22 Mar 2005 06:40:12 -0000	1.85
+++ compiler/mode_errors.m	22 Apr 2005 06:48:42 -0000
@@ -523,13 +523,13 @@
 	mercury_output_vars(Vars, VarSet, no),
 	io__write_string("'\n"),
 	prog_out__write_context(Context),
-	io__write_string("  have insts `"),
-	output_inst_list(Insts, ModeInfo0),
-	io__write_string("',\n"),
+	io__write_string("  have the following insts:\n"),
+	output_inst_list_sep_lines(Context, Insts, ModeInfo0),
 	prog_out__write_context(Context),
 	io__write_string("  which does not match any of the valid modes for\n"),
 	globals__io_lookup_bool_option(verbose_errors, VerboseErrors),
-	( { VerboseErrors = yes } ->
+	(
+		{ VerboseErrors = yes },
 		prog_out__write_context(Context),
 		io__write_string("  the callee ("),
 		hlds_out__write_pred_id(ModuleInfo, CalleePredId),
@@ -537,10 +537,12 @@
 		prog_out__write_context(Context),
 		io__write_string("  because of the following error.\n")
 	;
+		{ VerboseErrors = no },
 		prog_out__write_context(Context),
 		io__write_string("  the callee, because of the following error.\n")
 	),
-	( { CalleeModeErrors = [First | _] } ->
+	(
+		{ CalleeModeErrors = [First | _] },
 		{ First = mode_error_info(_, CalleeModeError,
 			CalleeContext, CalleeModeContext) },
 		{ mode_info_set_predid(CalleePredId, ModeInfo0, ModeInfo1) },
@@ -550,6 +552,7 @@
 			ModeInfo3, ModeInfo4) },
 		report_mode_error(CalleeModeError, ModeInfo4)
 	;
+		{ CalleeModeErrors = [] },
 		{ error("report_mode_error_in_callee: no error") }
 	).
 
@@ -565,9 +568,8 @@
 	mercury_output_vars(Vars, VarSet, no),
 	io__write_string("'\n"),
 	prog_out__write_context(Context),
-	io__write_string("  have insts `"),
-	output_inst_list(Insts, ModeInfo),
-	io__write_string("',\n"),
+	io__write_string("  have the following insts:\n"),
+	output_inst_list_sep_lines(Context, Insts, ModeInfo),
 	prog_out__write_context(Context),
 	io__write_string("  which does not match any of the modes for "),
 	{ mode_info_get_mode_context(ModeInfo, ModeContext) },
@@ -593,11 +595,13 @@
 	output_inst(VarInst, ModeInfo),
 	io__write_string("',\n"),
 	prog_out__write_context(Context),
-	(	{ PredOrFunc = predicate },
+	(
+		{ PredOrFunc = predicate },
 		io__write_string(
 			"  expecting higher-order pred inst (of arity "),
 		io__write_int(Arity)
-	;	{ PredOrFunc = function },
+	;
+		{ PredOrFunc = function },
 		io__write_string(
 			"  expecting higher-order func inst (of arity "),
 		{ Arity1 = Arity - 1 },
@@ -836,15 +840,18 @@
 	prog_out__write_context(Context),
 	io__write_string("  term `"),
 	hlds_out__write_functor_cons_id(ConsId, Args, VarSet, ModuleInfo, no),
-	( { Args \= [] } ->
+	(
+		{ Args = [_ | _] },
 		io__write_string("'\n"),
 		prog_out__write_context(Context),
 		io__write_string("  has instantiatedness `"),
 		mercury_output_cons_id(ConsId, does_not_need_brackets),
-		io__write_string("("),
-		output_inst_list(ArgInsts, ModeInfo),
-		io__write_string(")")
+		io__write_string("(\n"),
+		output_inst_list_sep_lines(Context, ArgInsts, ModeInfo),
+		prog_out__write_context(Context),
+		io__write_string("  )")
 	;
+		{ Args = [] },
 		io__write_string("' has instantiatedness `"),
 		mercury_output_cons_id(ConsId, does_not_need_brackets)
 	),
@@ -1101,23 +1108,41 @@
 
 :- pred output_inst((inst)::in, mode_info::in, io::di, io::uo) is det.
 
-output_inst(Inst0, ModeInfo) -->
-	{ strip_builtin_qualifiers_from_inst(Inst0, Inst) },
-	{ mode_info_get_instvarset(ModeInfo, InstVarSet) },
-	{ mode_info_get_module_info(ModeInfo, ModuleInfo) },
-	mercury_output_expanded_inst(Inst, InstVarSet, ModuleInfo).
+output_inst(Inst0, ModeInfo, !IO) :-
+	strip_builtin_qualifiers_from_inst(Inst0, Inst),
+	mode_info_get_instvarset(ModeInfo, InstVarSet),
+	mode_info_get_module_info(ModeInfo, ModuleInfo),
+	mercury_output_expanded_inst(Inst, InstVarSet, ModuleInfo, !IO).
 
 :- pred output_inst_list(list(inst)::in, mode_info::in, io::di, io::uo) is det.
 
-output_inst_list([], _) --> [].
-output_inst_list([Inst | Insts], ModeInfo) -->
-	output_inst(Inst, ModeInfo),
-	( { Insts = [] } ->
-		[]
+output_inst_list([], _, !IO).
+output_inst_list([Inst | Insts], ModeInfo, !IO) :-
+	output_inst(Inst, ModeInfo, !IO),
+	(
+		Insts = []
 	;
-		io__write_string(", "),
-		output_inst_list(Insts, ModeInfo)
+		Insts = [_ | _],
+		io__write_string(", ", !IO),
+		output_inst_list(Insts, ModeInfo, !IO)
 	).
+
+:- pred output_inst_list_sep_lines(prog_context::in, list(inst)::in,
+	mode_info::in, io::di, io::uo) is det.
+
+output_inst_list_sep_lines(_Context, [], _, !IO).
+output_inst_list_sep_lines(Context, [Inst | Insts], ModeInfo, !IO) :-
+	prog_out__write_context(Context, !IO),
+	io__write_string("    ", !IO),
+	output_inst(Inst, ModeInfo, !IO),
+	(
+		Insts = []
+	;
+		Insts = [_ | _],
+		io__write_string(",", !IO)
+	),
+	io__nl(!IO),
+	output_inst_list_sep_lines(Context, Insts, ModeInfo, !IO).
 
 %-----------------------------------------------------------------------------%
 
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
Index: tests/invalid/aditi_update_mode_errors.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/aditi_update_mode_errors.err_exp,v
retrieving revision 1.8
diff -u -b -r1.8 aditi_update_mode_errors.err_exp
--- tests/invalid/aditi_update_mode_errors.err_exp	23 Aug 2004 09:53:12 -0000	1.8
+++ tests/invalid/aditi_update_mode_errors.err_exp	22 Apr 2005 05:46:05 -0000
@@ -61,12 +61,18 @@
 aditi_update_mode_errors.m:102: In clause for `aditi_update_modes10((aditi.aditi_di), (aditi.aditi_uo))':
 aditi_update_mode_errors.m:102:   in call to function `int.+/2':
 aditi_update_mode_errors.m:102:   mode error: arguments `X0, V_12, V_10'
-aditi_update_mode_errors.m:102:   have insts `free, unique(1), free',
+aditi_update_mode_errors.m:102:   have the following insts:
+aditi_update_mode_errors.m:102:     free,
+aditi_update_mode_errors.m:102:     unique(1),
+aditi_update_mode_errors.m:102:     free
 aditi_update_mode_errors.m:102:   which does not match any of the modes for function `int.+/2'.
 aditi_update_mode_errors.m:105: In clause for `aditi_update_modes11((aditi.aditi_di), (aditi.aditi_uo))':
 aditi_update_mode_errors.m:105:   in call to function `int.+/2':
 aditi_update_mode_errors.m:105:   mode error: arguments `X0, V_12, V_10'
-aditi_update_mode_errors.m:105:   have insts `free, unique(1), free',
+aditi_update_mode_errors.m:105:   have the following insts:
+aditi_update_mode_errors.m:105:     free,
+aditi_update_mode_errors.m:105:     unique(1),
+aditi_update_mode_errors.m:105:     free
 aditi_update_mode_errors.m:105:   which does not match any of the modes for function `int.+/2'.
 aditi_update_mode_errors.m:115: In clause for `aditi_update_modes12((aditi.aditi_di), (aditi.aditi_uo))':
 aditi_update_mode_errors.m:115:   in argument 2 of `aditi_bulk_modify' of predicate `aditi_update_mode_errors.p/3':
Index: tests/invalid/ho_default_func_1.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/ho_default_func_1.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 ho_default_func_1.err_exp
--- tests/invalid/ho_default_func_1.err_exp	23 Aug 2004 09:53:13 -0000	1.3
+++ tests/invalid/ho_default_func_1.err_exp	22 Apr 2005 05:46:45 -0000
@@ -1,6 +1,9 @@
 ho_default_func_1.m:029: In clause for `baz(in, out)':
 ho_default_func_1.m:029:   in call to function `std_util.univ/1':
 ho_default_func_1.m:029:   mode error: arguments `TypeInfo_13, V_7, V_6'
-ho_default_func_1.m:029:   have insts `unique(private_builtin.type_info(unique(<type_ctor_info for .func/0>), unique(2), unique(<type_ctor_info for .int/0>), unique(<type_ctor_info for .int/0>))), /* unique */(func((free >> ground)) = (ground >> ground) is det), free',
+ho_default_func_1.m:029:   have the following insts:
+ho_default_func_1.m:029:     unique(private_builtin.type_info(unique(<type_ctor_info for .func/0>), unique(2), unique(<type_ctor_info for .int/0>), unique(<type_ctor_info for .int/0>))),
+ho_default_func_1.m:029:     /* unique */(func((free >> ground)) = (ground >> ground) is det),
+ho_default_func_1.m:029:     free
 ho_default_func_1.m:029:   which does not match any of the modes for function `std_util.univ/1'.
 For more information, try recompiling with `-E'.
Index: tests/invalid/ho_default_func_3.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/ho_default_func_3.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 ho_default_func_3.err_exp
--- tests/invalid/ho_default_func_3.err_exp	23 Aug 2004 09:53:13 -0000	1.3
+++ tests/invalid/ho_default_func_3.err_exp	22 Apr 2005 05:46:46 -0000
@@ -1,6 +1,9 @@
 ho_default_func_3.m:029: In clause for `baz(in, out)':
 ho_default_func_3.m:029:   in call to function `std_util.univ/1':
 ho_default_func_3.m:029:   mode error: arguments `TypeInfo_13, V_7, V_6'
-ho_default_func_3.m:029:   have insts `unique(private_builtin.type_info(unique(<type_ctor_info for .func/0>), unique(2), unique(<type_ctor_info for .int/0>), unique(<type_ctor_info for .int/0>))), /* unique */(func((unique >> clobbered)) = (free >> unique) is det), free',
+ho_default_func_3.m:029:   have the following insts:
+ho_default_func_3.m:029:     unique(private_builtin.type_info(unique(<type_ctor_info for .func/0>), unique(2), unique(<type_ctor_info for .int/0>), unique(<type_ctor_info for .int/0>))),
+ho_default_func_3.m:029:     /* unique */(func((unique >> clobbered)) = (free >> unique) is det),
+ho_default_func_3.m:029:     free
 ho_default_func_3.m:029:   which does not match any of the modes for function `std_util.univ/1'.
 For more information, try recompiling with `-E'.
Index: tests/invalid/mode_inf.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/mode_inf.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 mode_inf.err_exp
--- tests/invalid/mode_inf.err_exp	17 Jan 2003 05:57:09 -0000	1.3
+++ tests/invalid/mode_inf.err_exp	22 Apr 2005 05:46:57 -0000
@@ -1,7 +1,9 @@
 mode_inf.m:009: In clause for `p(out, out)':
 mode_inf.m:009:   in call to predicate `mode_inf.q/2':
 mode_inf.m:009:   mode error: arguments `X, Y'
-mode_inf.m:009:   have insts `free, free',
+mode_inf.m:009:   have the following insts:
+mode_inf.m:009:     free,
+mode_inf.m:009:     free
 mode_inf.m:009:   which does not match any of the valid modes for
 mode_inf.m:009:   the callee, because of the following error.
 mode_inf.m:011: In clause for `q(out(not_reached), out(not_reached))':
Index: tests/invalid/occurs.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/occurs.err_exp,v
retrieving revision 1.6
diff -u -b -r1.6 occurs.err_exp
--- tests/invalid/occurs.err_exp	19 Mar 2004 10:19:52 -0000	1.6
+++ tests/invalid/occurs.err_exp	22 Apr 2005 06:49:36 -0000
@@ -5,12 +5,16 @@
 occurs.m:008:   mode error in unification of `X' and `occurs.f(X)'.
 occurs.m:008:   Variable `X' has instantiatedness `free',
 occurs.m:008:   term `occurs.f(X)'
-occurs.m:008:   has instantiatedness `occurs.f(free)'.
+occurs.m:008:   has instantiatedness `occurs.f(
+occurs.m:008:     free
+occurs.m:008:   )'.
 occurs.m:018: In clause for `p3':
 occurs.m:018:   mode error in unification of `X' and `occurs.f(X)'.
 occurs.m:018:   Variable `X' has instantiatedness `unique(occurs.f(free))',
 occurs.m:018:   term `occurs.f(X)'
-occurs.m:018:   has instantiatedness `occurs.f(unique(occurs.f(free)))'.
+occurs.m:018:   has instantiatedness `occurs.f(
+occurs.m:018:     unique(occurs.f(free))
+occurs.m:018:   )'.
 occurs.m:010: In `p2':
 occurs.m:010:   warning: determinism declaration could be tighter.
 occurs.m:010:   Declared `semidet', inferred `failure'.
Index: tests/invalid/partial_implied_mode.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/partial_implied_mode.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 partial_implied_mode.err_exp
--- tests/invalid/partial_implied_mode.err_exp	20 Sep 2004 13:42:26 -0000	1.7
+++ tests/invalid/partial_implied_mode.err_exp	22 Apr 2005 06:50:40 -0000
@@ -2,5 +2,9 @@
 partial_implied_mode.m:033:   mode error in unification of `HeadVar__1' and `partial_implied_mode2.physic_quantity(V_11, V_4, V_12)'.
 partial_implied_mode.m:033:   Variable `HeadVar__1' has instantiatedness `unique(partial_implied_mode2.physic_quantity(ground, free, unique(partial_implied_mode2.absol(free, free))))',
 partial_implied_mode.m:033:   term `partial_implied_mode2.physic_quantity(V_11, V_4, V_12)'
-partial_implied_mode.m:033:   has instantiatedness `partial_implied_mode2.physic_quantity(free, ground, free)'.
+partial_implied_mode.m:033:   has instantiatedness `partial_implied_mode2.physic_quantity(
+partial_implied_mode.m:033:     free,
+partial_implied_mode.m:033:     ground,
+partial_implied_mode.m:033:     free
+partial_implied_mode.m:033:   )'.
 For more information, try recompiling with `-E'.
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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