[m-rev.] for review: improve typeclass constraints error messages

Julien Fischer juliensf at csse.unimelb.edu.au
Tue Aug 18 17:58:14 AEST 2009


On Tue, 18 Aug 2009, Peter Wang wrote:

> [the first copy of this seems not to have come through]
>
> Branches: main
>
> Improve two error messages related to typeclass constraints.
>
> 1. The "unsatisfied typeclass constraints" error message didn't tell the user
> the line numbers of the atomic goals which originated the constraints.
>
> 2. The "unsatisfiable typeclass constraints" error message told the user that
> a set of constraints couldn't be satisfied, including the constraints it
> proved to be satisfiable.  Also, it would list a top-level constraint in the
> error message when some of the constraint's descendents could be satisfied.
> It is more useful to tell the user about the descendants that couldn't be
> satisfied.  Bug #35.
>
> compiler/post_typecheck.m:
>        Fix the first problem.
>
> compiler/typeclasses.m:
>        Fix the second problem.
>
> tests/invalid/Mmakefile:
> tests/invalid/typeclass_test_8.err_exp:
> tests/invalid/unsatisfiable_constraint.err_exp:
> tests/invalid/unsatisfiable_constraint_msg.err_exp:
> tests/invalid/unsatisfiable_constraint_msg.m:
>        Add test case and update expected error output.

...

> diff --git a/tests/invalid/typeclass_test_8.err_exp b/tests/invalid/typeclass_test_8.err_exp
> index e4aa1af..d610001 100644
> --- a/tests/invalid/typeclass_test_8.err_exp
> +++ b/tests/invalid/typeclass_test_8.err_exp
> @@ -1,7 +1,4 @@
> typeclass_test_8.m:004: In predicate `main'/2:
> -typeclass_test_8.m:004:   type error: unsatisfied typeclass constraint:
> -typeclass_test_8.m:004:     `typeclass_test_8.fooable(T)'
> -typeclass_test_8.m:004: In predicate `main'/2:
> typeclass_test_8.m:004:   warning: unresolved polymorphism.
> typeclass_test_8.m:004:   The variable with an unbound type was:
> typeclass_test_8.m:004:     X: T
> @@ -13,3 +10,9 @@ typeclass_test_8.m:004:   version should be called, because the type variables
> typeclass_test_8.m:004:   listed above didn't get bound. (I ought to tell you
> typeclass_test_8.m:004:   which call caused the problem, but I'm afraid you'll
> typeclass_test_8.m:004:   have to work it out yourself. My apologies.)
> +typeclass_test_8.m:004: In predicate `main'/2:
> +typeclass_test_8.m:004:   type error: unsatisfied typeclass constraint:
> +typeclass_test_8.m:004:     `typeclass_test_8.fooable(T)'
> +typeclass_test_8.m:004:   The constraint is due to:
> +typeclass_test_8.m:013:     a goal here, and
> +typeclass_test_8.m:014:     a goal here.

One suggestion:

It might be nicer to say what the goals are, for example instead of

 	a goal here, and
 	a goal here.

this:
 	the call to foo/4, and
 	the unification between `X' and `Y'.


The diff looks fine otherwise.

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list