[m-dev.] diff: fix undefined modes bug
Fergus Henderson
fjh at cs.mu.OZ.AU
Sat Sep 16 11:02:06 AEDT 2000
Estimated hours taken: 1.5
Fix a bug reported by Peter Ross <peter.ross at miscrit.be> where
for certain invalid code the compiler would, after correctly reporting
an error message, throw an exception.
compiler/typecheck.m:
For predicates that have type errors, don't call
post_typecheck__finish_ill_typed_pred, since (a) it's not
needed any more, and (b) if there are undefined modes,
post_typecheck__finish_ill_typed_pred can end up calling
error/1.
tests/invalid/Mmakefile:
tests/invalid/undef_mode_and_no_clauses.m:
tests/invalid/undef_mode_and_no_clauses.err_exp:
A regression test.
Workspace: /home/pgrad/fjh/ws/hg
Index: compiler/typecheck.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.278
diff -u -d -r1.278 typecheck.m
--- compiler/typecheck.m 2000/08/09 07:47:57 1.278
+++ compiler/typecheck.m 2000/09/15 23:54:33
@@ -158,7 +158,6 @@
:- implementation.
-:- import_module post_typecheck.
:- import_module hlds_goal, prog_util, type_util, modules, code_util.
:- import_module prog_io, prog_io_util, prog_out, hlds_out, error_util.
:- import_module mercury_to_mercury, mode_util, options, getopt, globals.
@@ -276,6 +275,15 @@
ModuleInfo2) }
;
{ Error1 = yes },
+ /********************
+ This code is not needed at the moment,
+ since currently we don't run mode analysis if
+ there are any type errors.
+ And this code also causes problems:
+ if there are undefined modes,
+ this code can end up calling error/1,
+ since post_typecheck__finish_ill_typed_pred
+ assumes that there are no undefined modes.
%
% if we get an error, we need to call
% post_typecheck__finish_ill_typed_pred on the
@@ -288,6 +296,8 @@
post_typecheck__finish_ill_typed_pred(ModuleInfo0,
PredId, PredInfo1, PredInfo),
{ map__det_update(Preds0, PredId, PredInfo, Preds) },
+ *******************/
+ { map__det_update(Preds0, PredId, PredInfo1, Preds) },
{ module_info_set_preds(ModuleInfo0, Preds,
ModuleInfo1) },
{ module_info_remove_predid(ModuleInfo1, PredId,
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.68
diff -u -d -r1.68 Mmakefile
--- tests/invalid/Mmakefile 2000/09/15 23:45:48 1.68
+++ tests/invalid/Mmakefile 2000/09/15 23:59:57
@@ -86,6 +86,7 @@
unbound_inst_var.m \
undef_lambda_mode.m \
undef_mode.m \
+ undef_mode_and_no_clauses.m \
undef_mod_qual.m \
undef_symbol.m \
undef_type.m \
Index: tests/invalid/undef_mode_and_no_clauses.err_exp
===================================================================
RCS file: undef_mode_and_no_clauses.err_exp
diff -N undef_mode_and_no_clauses.err_exp
--- /dev/null Thu Mar 30 14:06:13 2000
+++ undef_mode_and_no_clauses.err_exp Sat Sep 16 10:59:32 2000
@@ -0,0 +1,5 @@
+undef_mode_and_no_clauses.m:012: In mode declaration for predicate `undef_mode_and_no_clauses:p'/2:
+undef_mode_and_no_clauses.m:012: error: undefined mode `result'/1.
+undef_mode_and_no_clauses.m:011: Error: no clauses for
+undef_mode_and_no_clauses.m:011: predicate `undef_mode_and_no_clauses:p/2'.
+For more information, try recompiling with `-E'.
Index: tests/invalid/undef_mode_and_no_clauses.m
===================================================================
RCS file: undef_mode_and_no_clauses.m
diff -N undef_mode_and_no_clauses.m
--- /dev/null Thu Mar 30 14:06:13 2000
+++ undef_mode_and_no_clauses.m Thu Jul 20 17:44:43 2000
@@ -0,0 +1,14 @@
+% This is a regression test for a bug that showed up in
+% version rotd-2000-08-12.
+% After correctly reporting the errors in this code,
+% the compiler threw an exception.
+
+:- module undef_mode_and_no_clauses.
+:- interface.
+:- type result(T) ---> ok(T).
+:- implementation.
+
+:- pred p(pred(T), result(T)).
+:- mode p(pred(out) is det, result(T)) is det. % mode result/1 not defined
+
+% no clauses for p/2
--
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