[m-rev.] fix missed mode error for free-free unification
Fergus Henderson
fjh at cs.mu.OZ.AU
Sun Aug 3 23:32:45 AEST 2003
Estimated hours taken: 2
Branches: main
Fix a bug where we were missing mode errors, and in some cases generating
incorrect code as a result.
compiler/modecheck_unify.m:
Disallow the case of free-free unifications where both variables
are locked.
tests/invalid/Mmakefile:
tests/invalid/freefree.err_exp
Enable the freefree test case, since we now pass it.
BUGS:
Delete the bug report for this bug.
Workspace: /home/ceres/fjh/mercury
Index: BUGS
===================================================================
RCS file: /home/mercury1/repository/mercury/BUGS,v
retrieving revision 1.17
diff -u -d -r1.17 BUGS
--- BUGS 25 Jun 2003 06:57:33 -0000 1.17
+++ BUGS 3 Aug 2003 10:48:54 -0000
@@ -120,36 +120,6 @@
but I thought I'd point it out to you before I forgot it.
-----------------------------------------------------------------------------
-Subject: missed mode error
-Date: Tue, 28 May 1996 02:27:34 +1000 (EST)
-
-Another one for the bug report file:
-
-The goal `some [X, Y] X \= Y' should be a mode error,
-but the current mode checker doesn't report an error.
-Instead, the compiler goes on to generate code which gives
-the wrong answer. For example, the following program prints out `no'.
-The same problem also occurs with `some [X, Y] (X = Y -> fail ; true)'.
-
-:- module bug.
-:- interface.
-:- import_module io.
-
-:- pred main(io__state::di, io__state::uo) is det.
-
-:- implementation.
-
-main -->
- ( { p } -> io__write_string("yes\n") ; io__write_string("no\n") ).
-
-:- pred p is semidet.
-p :-
- some [X, Y] X \= Y.
-
-The bug occurs only when the variables being unified inside a negated
-context are not live, i.e. when it is the last occurrence of those variables.
-
------------------------------------------------------------------------------
Subject: bug with PC values on Alpha
Date: Wed, 12 Jun 1996 15:45:59 +1000
Index: compiler/modecheck_unify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modecheck_unify.m,v
retrieving revision 1.60
diff -u -d -r1.60 modecheck_unify.m
--- compiler/modecheck_unify.m 25 Jul 2003 02:27:22 -0000 1.60
+++ compiler/modecheck_unify.m 3 Aug 2003 10:25:15 -0000
@@ -88,7 +88,21 @@
BothLive = dead
),
abstractly_unify_inst(BothLive, InstOfX, InstOfY,
- real_unify, ModuleInfo0, UnifyInst, Det1, ModuleInfo1)
+ real_unify, ModuleInfo0, UnifyInst, Det1, ModuleInfo1),
+ % Don't allow free-free unifications if both variables are
+ % locked. (Normally the checks for binding locked variables
+ % are done in modecheck_set_var_inst, which is called below,
+ % but that won't catch this case, because the inst of the
+ % variable will remain `free'. XXX are there other cases
+ % like this one?)
+ \+ (
+ UnifyInst = free,
+ mode_info_var_is_locked(ModeInfo0, X, _XLockedReason),
+ mode_info_var_is_locked(ModeInfo0, Y, _YLockedReason),
+ % a unification of the form `X = X' doesn't bind X,
+ % and thus should be allowed even if X is locked
+ X \= Y
+ )
->
Inst = UnifyInst,
Det = Det1,
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.139
diff -u -d -r1.139 Mmakefile
--- tests/invalid/Mmakefile 25 Jul 2003 06:30:08 -0000 1.139
+++ tests/invalid/Mmakefile 3 Aug 2003 10:17:30 -0000
@@ -69,6 +69,7 @@
foreign_type_visibility \
func_errors \
funcs_as_preds \
+ freefree \
ho_default_func_1 \
ho_default_func_3 \
ho_type_mode_bug \
@@ -175,7 +176,6 @@
# when doing dynamic linking, or when the library
# was built with `--split-c-files')
# parent.undeclared_child (just not yet implemented)
-# freefree (need bromage's aliasing stuff)
# typeclass_test_8 (minor formatting error in the output --
# the type class name should be in quotes)
# typeclass_mode_{2,3,4} (compiler calls error/1)
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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