[m-dev.] diff: improve error messages
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue Sep 19 03:06:13 AEDT 2000
Estimated hours taken: 0.5
compiler/typecheck.m:
Improve the error messages for syntax errors in lambda
expressions and field selection/update expressions.
tests/invalid/Mmakefile:
tests/invalid/field_syntax_error.m:
tests/invalid/field_syntax_error.err_exp:
tests/invalid/lambda_syntax_error.m:
tests/invalid/lambda_syntax_error.err_exp:
Regression tests.
Workspace: /home/pgrad/fjh/ws/hg
Index: compiler/typecheck.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.282
diff -u -d -r1.282 typecheck.m
--- compiler/typecheck.m 2000/09/12 01:34:58 1.282
+++ compiler/typecheck.m 2000/09/18 15:55:41
@@ -5549,6 +5549,37 @@
;
[]
)
+ ; { Functor = cons(unqualified("^"), 2) } ->
+ io__write_string(
+ " error: invalid use of field selection operator (`^').\n"),
+ globals__io_lookup_bool_option(verbose_errors, VerboseErrors),
+ ( { VerboseErrors = yes } ->
+ prog_out__write_context(Context),
+ io__write_string(
+ " This is probably some kind of syntax error.\n"),
+ prog_out__write_context(Context),
+ io__write_string(
+ " The field name must be an atom, not a variable or other term.\n")
+ ;
+ []
+ )
+ ; { Functor = cons(unqualified(":="), 2) } ->
+ io__write_string(
+ " error: invalid use of field update operator (`:=').\n"),
+ globals__io_lookup_bool_option(verbose_errors, VerboseErrors),
+ ( { VerboseErrors = yes } ->
+ prog_out__write_context(Context),
+ io__write_string(
+ " This is probably some kind of syntax error.\n")
+ ;
+ []
+ )
+ ; { Functor = cons(unqualified(":-"), 2) } ->
+ io__write_string(
+ " syntax error in lambda expression (`:-').\n")
+ ; { Functor = cons(unqualified("-->"), 2) } ->
+ io__write_string(
+ " syntax error in DCG lambda expression (`-->').\n")
; { InvalidFieldUpdates = [_ | _] } ->
io__write_string(
" error: invalid field update `"),
Index: tests/invalid/field_syntax_error.err_exp
===================================================================
RCS file: field_syntax_error.err_exp
diff -N field_syntax_error.err_exp
--- /dev/null Thu Mar 30 14:06:13 2000
+++ field_syntax_error.err_exp Tue Sep 19 01:47:43 2000
@@ -0,0 +1,25 @@
+field_syntax_error.m:013: In clause for function `field_syntax_error:baz/1':
+field_syntax_error.m:013: warning: variable `Bar' occurs only once in this scope.
+field_syntax_error.m:015: In clause for function `field_syntax_error:baz3/1':
+field_syntax_error.m:015: warning: variable `Bar' occurs only once in this scope.
+field_syntax_error.m:013: In clause for function `field_syntax_error:baz/1':
+field_syntax_error.m:013: in function result term of clause head:
+field_syntax_error.m:013: error: invalid use of field selection operator (`^').
+field_syntax_error.m:014: In clause for function `field_syntax_error:baz2/1':
+field_syntax_error.m:014: in function result term of clause head:
+field_syntax_error.m:014: error: invalid use of field selection operator (`^').
+field_syntax_error.m:015: In clause for function `field_syntax_error:baz3/1':
+field_syntax_error.m:015: in function result term of clause head:
+field_syntax_error.m:015: error: invalid use of field update operator (`:=').
+field_syntax_error.m:015: In clause for function `field_syntax_error:baz3/1':
+field_syntax_error.m:015: in function result term of clause head:
+field_syntax_error.m:015: in argument 1 of functor `:=/2':
+field_syntax_error.m:015: error: invalid use of field selection operator (`^').
+field_syntax_error.m:016: In clause for function `field_syntax_error:baz4/1':
+field_syntax_error.m:016: in function result term of clause head:
+field_syntax_error.m:016: error: invalid use of field update operator (`:=').
+field_syntax_error.m:016: In clause for function `field_syntax_error:baz4/1':
+field_syntax_error.m:016: in function result term of clause head:
+field_syntax_error.m:016: in argument 1 of functor `:=/2':
+field_syntax_error.m:016: error: invalid use of field selection operator (`^').
+For more information, try recompiling with `-E'.
Index: tests/invalid/field_syntax_error.m
===================================================================
RCS file: field_syntax_error.m
diff -N field_syntax_error.m
--- /dev/null Thu Mar 30 14:06:13 2000
+++ field_syntax_error.m Tue Sep 19 01:45:46 2000
@@ -0,0 +1,17 @@
+:- module field_syntax_error.
+:- interface.
+
+:- type foo ---> f(bar :: int).
+
+:- func baz(foo) = int.
+:- func baz2(foo) = int.
+:- func baz3(foo) = int.
+:- func baz4(foo) = int.
+
+:- implementation.
+
+baz(Foo) = Foo^Bar.
+baz2(Foo) = Foo^42.
+baz3(Foo) = Foo^Bar:=43.
+baz4(Foo) = Foo^44:=45.
+
Index: tests/invalid/lambda_syntax_error.err_exp
===================================================================
RCS file: lambda_syntax_error.err_exp
diff -N lambda_syntax_error.err_exp
--- /dev/null Thu Mar 30 14:06:13 2000
+++ lambda_syntax_error.err_exp Tue Sep 19 03:01:55 2000
@@ -0,0 +1,57 @@
+lambda_syntax_error.m:012: In clause for function `lambda_syntax_error:baz/1':
+lambda_syntax_error.m:012: in function result term of clause head:
+lambda_syntax_error.m:012: syntax error in lambda expression (`:-').
+lambda_syntax_error.m:012: In clause for function `lambda_syntax_error:baz/1':
+lambda_syntax_error.m:012: in function result term of clause head:
+lambda_syntax_error.m:012: in argument 1 of functor `:-/2':
+lambda_syntax_error.m:012: error: undefined symbol `pred/1'.
+lambda_syntax_error.m:013: In clause for function `lambda_syntax_error:baz2/1':
+lambda_syntax_error.m:013: in function result term of clause head:
+lambda_syntax_error.m:013: syntax error in lambda expression (`:-').
+lambda_syntax_error.m:013: In clause for function `lambda_syntax_error:baz2/1':
+lambda_syntax_error.m:013: in function result term of clause head:
+lambda_syntax_error.m:013: in argument 1 of functor `:-/2':
+lambda_syntax_error.m:013: error: undefined symbol `pred/1'.
+lambda_syntax_error.m:013: In clause for function `lambda_syntax_error:baz2/1':
+lambda_syntax_error.m:013: in function result term of clause head:
+lambda_syntax_error.m:013: in argument 1 of functor `:-/2':
+lambda_syntax_error.m:013: in argument 1 of functor `pred/1':
+lambda_syntax_error.m:013: error: undefined symbol `::/2'.
+lambda_syntax_error.m:013: In clause for function `lambda_syntax_error:baz2/1':
+lambda_syntax_error.m:013: in function result term of clause head:
+lambda_syntax_error.m:013: in argument 1 of functor `:-/2':
+lambda_syntax_error.m:013: in argument 1 of functor `pred/1':
+lambda_syntax_error.m:013: in argument 2 of functor `::/2':
+lambda_syntax_error.m:013: error: undefined symbol `in/0'.
+lambda_syntax_error.m:014: In clause for function `lambda_syntax_error:baz3/1':
+lambda_syntax_error.m:014: in function result term of clause head:
+lambda_syntax_error.m:014: syntax error in lambda expression (`:-').
+lambda_syntax_error.m:014: In clause for function `lambda_syntax_error:baz3/1':
+lambda_syntax_error.m:014: in function result term of clause head:
+lambda_syntax_error.m:014: in argument 1 of functor `:-/2':
+lambda_syntax_error.m:014: in argument 1 of functor `is/2':
+lambda_syntax_error.m:014: error: undefined symbol `pred/1'.
+lambda_syntax_error.m:014: In clause for function `lambda_syntax_error:baz3/1':
+lambda_syntax_error.m:014: in function result term of clause head:
+lambda_syntax_error.m:014: in argument 1 of functor `:-/2':
+lambda_syntax_error.m:014: in argument 2 of functor `is/2':
+lambda_syntax_error.m:014: error: undefined symbol `semidet/0'.
+lambda_syntax_error.m:015: In clause for function `lambda_syntax_error:baz4/1':
+lambda_syntax_error.m:015: in function result term of clause head:
+lambda_syntax_error.m:015: syntax error in lambda expression (`:-').
+lambda_syntax_error.m:015: In clause for function `lambda_syntax_error:baz4/1':
+lambda_syntax_error.m:015: in function result term of clause head:
+lambda_syntax_error.m:015: in argument 1 of functor `:-/2':
+lambda_syntax_error.m:015: error: the language construct =/2 should be
+lambda_syntax_error.m:015: used as a goal, not as an expression.
+lambda_syntax_error.m:015: In clause for function `lambda_syntax_error:baz4/1':
+lambda_syntax_error.m:015: in function result term of clause head:
+lambda_syntax_error.m:015: in argument 1 of functor `:-/2':
+lambda_syntax_error.m:015: in argument 1 of functor `=/2':
+lambda_syntax_error.m:015: error: undefined symbol `pred/1'.
+lambda_syntax_error.m:015: In clause for function `lambda_syntax_error:baz4/1':
+lambda_syntax_error.m:015: in function result term of clause head:
+lambda_syntax_error.m:015: in argument 2 of functor `:-/2':
+lambda_syntax_error.m:015: error: the language construct =/2 should be
+lambda_syntax_error.m:015: used as a goal, not as an expression.
+For more information, try recompiling with `-E'.
Index: tests/invalid/lambda_syntax_error.m
===================================================================
RCS file: lambda_syntax_error.m
diff -N lambda_syntax_error.m
--- /dev/null Thu Mar 30 14:06:13 2000
+++ lambda_syntax_error.m Tue Sep 19 03:00:01 2000
@@ -0,0 +1,16 @@
+:- module lambda_syntax_error.
+:- interface.
+
+:- some [T] func baz(int) = T.
+:- some [T] func baz2(int) = T.
+:- some [T] func baz3(int) = T.
+:- some [T] func baz4(int) = T.
+
+:- implementation.
+:- import_module int.
+
+baz(X) = (pred(Y) :- X > Y). % modes & determinism not specified
+baz2(X) = (pred(Y::in) :- X > Y). % determinism not specified
+baz3(X) = (pred(Y) is semidet :- X > Y). % mode not specified
+baz4(X) = (pred(A) = B :- X = A + B). % mixing `func' and `pred' notation
+
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.72
diff -u -d -r1.72 Mmakefile
--- tests/invalid/Mmakefile 2000/08/17 02:14:49 1.72
+++ tests/invalid/Mmakefile 2000/09/18 16:02:16
@@ -38,6 +38,7 @@
external.m \
ext_type_bug.m \
exported_mode.m \
+ field_syntax_error.m \
func_errors.m \
funcs_as_preds.m \
ho_type_mode_bug.m \
@@ -47,6 +48,7 @@
invalid_main.m \
inst_list_dup.m \
io_in_ite_cond.m \
+ lambda_syntax_error.m \
missing_det_decls.m \
missing_interface_import.m \
modes_erroneous.m \
--
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.
--------------------------------------------------------------------------
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