[m-dev.] for review: superclass bug fix

Tyson Dowd trd at cs.mu.OZ.AU
Mon Nov 6 14:59:34 AEDT 2000


On 30-Oct-2000, David Glen JEFFERY <dgj at students.cs.mu.oz.au> wrote:
> Hi,
> 
> This one's for Fergus.
> 
> --------------------------------------------------------------------------
> 
> Estimated hours taken: 5
> 
> Fix a bug reported by petdr.
> 
> compiler/typecheck.m:
> 	When searching the superclass relation trying to reduce a constraint C, 
> 	we were holding all the variables in C as constant and allowing any
> 	others to be found. (The theory being that any other variables must be
> 	variables introduced during the search eg. by a multiparameter 
> 	typeclass that uses less than all of its parameters in one of its
> 	superclass constraint. These variables are effectively existentially
> 	quantified).
> 	However, this is not enough: variables from *other* assumed constraints
> 	must also not be bound, otherwise you risk binding the variables from
> 	another assumed constraint to the variables in C.
> 
> 	So... now we do not bind any of the head_type_params (which makes sense
> 	given that these are the variables that are universally quantified from
> 	the head or existentially quantified from the body).
> 
> 	This required passing the head_type_params down a couple of levels,
> 	including typecheck__reduce_context_by_rule_application, which is
> 	exported.
> 
> compiler/check_typeclass.m:
> 	Add the new argument to the call to
> 	typecheck__reduce_context_by_rule_application.
> 
> tests/hard_coded/typeclasses/Mmakefile:
> tests/hard_coded/typeclasses/superclass_bug.exp:
> tests/hard_coded/typeclasses/superclass_bug.m:
> 	A test case for this. This test case was giving an abort during
> 	polymorphism because the constraint proof that had been recorded
> 	was invalid. (The program was still type correct, but the type
> 	checker had recorded a bogus proof).

I won't pretend to understand the meaning of the fix, but the code
itself looks fine.  Commit away.

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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