[m-rev.] for review: fix typeclass bug
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Mar 12 19:37:14 AEDT 2003
On 12-Mar-2003, David Overton <dmo at cs.mu.OZ.AU> wrote:
>
> compiler/typecheck.m:
> In `eliminate_constraint_by_class_rules', if `type_unify_list'
> fails for a subclass, remove that subclass from the list of
> constraints being examined rather than aborting.
> `type_unify_list' may fail if one of the arguments to the
> superclass constraint is not a type variable and does not unify
> with the corresponding argument of the subclass.
> In such cases, this particular superclass-subclass relationship
> is not relevant to the constraint we are trying to prove so it is safe
> to remove it.
Could you explain in more detail? Perhaps with an example?
I'm not yet completely convinced that removing such constraints is safe.
> tests/valid/Mmakefile:
> tests/valid/typeclass_constraint_nonvar_bug.m:
> Test case.
The test case does not seem to be a proper regression test, since this
test passes with the existing compiler (I tested with rotd-2003-03-08).
> Index: compiler/typecheck.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/typecheck.m,v
> retrieving revision 1.331
> diff -u -r1.331 typecheck.m
> --- compiler/typecheck.m 28 Feb 2003 06:40:43 -0000 1.331
> +++ compiler/typecheck.m 12 Mar 2003 03:50:54 -0000
> @@ -4629,7 +4629,8 @@
> % Convert all the subclass_details into class_constraints by
> % doing the appropriate variable renaming and applying the
> % type variable bindings.
> - list__map(subclass_details_to_constraint(TVarSet, SuperClassTypes),
> + list__filter_map(subclass_details_to_constraint(TVarSet,
> + SuperClassTypes),
Please update the comment here. This is now doing more than just
converting things, it is also removing some contraints.
(E.g. with text similar to that in the log message.)
> SubClasses, SubClassConstraints),
>
> (
> @@ -4720,7 +4721,7 @@
> ).
>
> :- pred subclass_details_to_constraint(tvarset::in, list(type)::in,
> - subclass_details::in, class_constraint::out) is det.
> + subclass_details::in, class_constraint::out) is semidet.
Please add some comments here indicating when the procedure will succeed
and when it will fail.
--
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