[m-rev.] diff: print contexts for variables in parsing error messages
Ian MacLarty
maclarty at csse.unimelb.edu.au
Thu Aug 9 13:47:29 AEST 2007
Estimated hours taken: 0.5
Branches: main
Print contexts for parsing errors involving unexpected variables.
compiler/prog_out.m:
Print contexts when the incorrect term is a variable.
tests/invalid/vars_in_wrong_places.err_exp:
Expect contexts.
Index: compiler/prog_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_out.m,v
retrieving revision 1.81
diff -u -r1.81 prog_out.m
--- compiler/prog_out.m 19 Jan 2007 07:04:28 -0000 1.81
+++ compiler/prog_out.m 8 Aug 2007 04:47:18 -0000
@@ -202,13 +202,10 @@
:- pred write_message(pair(string, term)::in, io::di, io::uo) is det.
write_message(Msg - Term, !IO) :-
- ( Term = term.functor(_Functor, _Args, Context0) ->
- Context0 = term.context(File, Line),
- Context = term.context(File, Line),
- write_context(Context, !IO)
- ;
- true
+ ( Term = term.functor(_Functor, _Args, Context)
+ ; Term = term.variable(_Var, Context)
),
+ write_context(Context, !IO),
io.write_string(Msg, !IO),
( Term = term.functor(term.atom(""), [], _Context2) ->
io.write_string(".\n", !IO)
Index: tests/invalid/vars_in_wrong_places.err_exp
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/vars_in_wrong_places.err_exp,v
retrieving revision 1.8
diff -u -r1.8 vars_in_wrong_places.err_exp
--- tests/invalid/vars_in_wrong_places.err_exp 1 Oct 2006 04:24:12 -0000 1.8
+++ tests/invalid/vars_in_wrong_places.err_exp 9 Aug 2007 03:40:48 -0000
@@ -1,9 +1,9 @@
vars_in_wrong_places.m:002: Error: atom expected in clause head: _1 :- blah.
vars_in_wrong_places.m:003: Error: atom expected in equation head: _1 = 42.
vars_in_wrong_places.m:004: Error: atom expected in equation head: _1 = 42.
-Error: atom expected in `:- pred' declaration: _1.
+vars_in_wrong_places.m:005: Error: atom expected in `:- pred' declaration: _1.
vars_in_wrong_places.m:006: Error: atom expected in `:- func' declaration: _1 = int.
-Error: atom expected in `:- mode' declaration: _1.
+vars_in_wrong_places.m:007: Error: atom expected in `:- mode' declaration: _1.
vars_in_wrong_places.m:008: Error: atom expected in function `:- mode' declaration: _1 = int.
vars_in_wrong_places.m:001: Warning: interface for module
vars_in_wrong_places.m:001: `vars_in_wrong_places' does not export anything.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list