[m-dev.] Re: Reminder: Mercury tests failing

David Overton dmo at cs.mu.OZ.AU
Fri May 30 16:56:59 AEST 2003


Hi Fergus,

On Fri, May 30, 2003 at 06:30:06AM +1000, Mercury wrote:
> This is an automatic reminder.
> Some of the tests in the Mercury test suite are failing,
> apparently due to a change that you made (or approved).
> The issue in question is this:
> 
> (currently there is no test in the test suite for this one,
> but nevertheless it is a regression)
> 
> The following program seg faults, due to a problem with
> co/contravariance in higher-order inst matching.
> 
> 	:- module bug.
> 	:- interface.
> 	:- import_module io.
> 	 
> 	:- pred main(io__state::di, io__state::uo) is det.
> 	 
> 	:- implementation.
> 	:- import_module list, bool.
> 	 
> 	main -->
> 		( { q(p) } ->
> 			print("yes"), nl
> 		;
> 			print("no"), nl
> 		).
> 	 
> 	:- type intlist == list(int).
> 	:- inst nonempty ---> [ground|ground].
> 	 
> 	:- pred p(intlist, intlist).
> 	:- mode p(in(nonempty), out(nonempty)) is det.
> 	 
> 	p([X], [X]).
> 	p([X,Y|Zs], [Y,X|Zs]).
> 	 
> 	:- pred q(pred(intlist, intlist)).
> 	:- mode q(pred(in, out) is det) is semidet.
> 	 
> 	q(P) :- P([], L), L \= [].
> 
> 
> If you have any questions about this email,
> please ask fjh at cs.mu.oz.au or mercury at cs.mu.oz.au.

I've had a look at this.  The problem is that
inst_matches_final(ground, bound(...)) is unsafe.  This has been the
case since at least 1995.  Version 1.1 of inst_match.m in the CVS
repository has this bug.  Here is the relevant clause from that version:

inst_matches_final_3(ground, bound(ListB), ModuleInfo, _Expansions) :-
        bound_inst_list_is_ground(ListB, ModuleInfo).
                % XXX BUG! Should fail if there are not_reached
                % insts in ListB, or if ListB does not contain a complete list
                % of all the constructors for the type in question.

I tried to fix this a few years ago by adding type information to
determine when it was safe.  However, at that time I found that it made
the mode checker too conservative in the absence of alias tracking so
the bug has never been fixed.  I'll have another look at it and see what
I can do.

I've just quickly tried to fix the bug and bootstrap, however it has
detected mode errors in exception.m, e.g. try/3 is not mode correct in
some modes because its mode declarations are more precise than the
declarations for catch_impl/3 which it calls.


David
-- 
David Overton                  Uni of Melbourne     +61 3 8344 1354
dmo at cs.mu.oz.au                Monash Uni (Clayton) +61 3 9905 5779
http://www.cs.mu.oz.au/~dmo    Mobile Phone         +61 4 0337 4393
--------------------------------------------------------------------------
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