[m-rev.] Re: for review: default modes for higher-order func insts

David Overton dmo at cs.mu.OZ.AU
Fri Oct 12 00:44:54 AEST 2001


On Thu, Oct 11, 2001 at 08:11:34PM +1000, Simon Taylor wrote:
> > 
> > Yes, you are right.  The reason no mode error is reported is because of
> > this code in inst_match.m, which does the required check and the ignores
> > the result:
> > 
> > inst_matches_final_3(ground(UniqA, GroundInstInfoA), bound(UniqB, ListB),
> > 		MaybeType, Info, Info) :-
> > 	\+ ground_inst_info_is_nonstandard_func_mode(GroundInstInfoA,
> > 		Info^module_info),
> > 	unique_matches_final(UniqA, UniqB),
> > 	bound_inst_list_is_ground(ListB, Info^module_info),
> > 	uniq_matches_bound_inst_list(UniqA, ListB, Info^module_info),
> > 	(
> > 		MaybeType = yes(Type),
> > 		% We can only do this check if the type is known.
> > 		bound_inst_list_is_complete_for_type(set__init,
> > 			Info^module_info, ListB, Type)
> > 	;
> > 		true
> > 		% XXX enabling the check for bound_inst_list_is_complete
> > 		% for type makes the mode checker too conservative in
> > 		% the absence of alias tracking, so we currently always
> > 		% succeed, even if this check fails.
> > 	).
> > 
> > 
> > I will remove that test from the test case.
> 
> One of the major advantages of Mercury over languages like C
> is that code which passes the compiler's checking passes cannot
> crash unless it runs out of resources (stack or heap). The code
> above can cause crashes (see the test case below). We haven't
> implemented nested unique modes because the mode checker doesn't
> do alias tracking. Why is this case any different?

Yes, I agree completely.  Unfortunately, this part of the mode checker
has always been broken in this way, and when I tried to fix it last year
(when I added the call to bound_inst_list_is_complete_for_type) it
became too conservative and broke some existing code (in the library
IIRC).  That is why the 'true' disjunct is there --- it basically
returns it to the previous behaviour.

I don't think the library code would be too hard to change to allow the
mode checker to pass it with this test case, but I wasn't sure what else
it might break so at the time I chose to stay with the status quo.

I will try re-enabling the check here (not this week though -- I have
other stuff to do) and see what else breaks and how easy it is to fix.
This should be a separate change from the one this thread is discussing,
though.


David
-- 
David Overton      Department of Computer Science & Software Engineering
PhD Student        The University of Melbourne, Victoria 3010, Australia
+61 3 8344 9159    http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
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