[mercury-users] mode error

Tom Schrijvers Tom.Schrijvers at cs.kuleuven.ac.be
Sat Aug 10 00:14:53 AEST 2002


> Basically the problem is that you need to module-qualify the functor
> names in the inst definitions.  Normally the compiler will infer the
> right module qualifiers to use based on the type.  However, in this
> case your insts are used as the inst of a polymorphically-typed variable
> (the first argument to eval/1) and the compiler therefore can't determine
> the appropriate module qualifiers from the type.
>
> Your mail has spurred me to improve the compiler's diagnostics.
> I modified my local version of the compiler so that it expands out
> insts in error messages.  If the inst is recursive, then it just
> prints out "..." once it gets to the recursive part.
>
> With my modified version of the compiler, I get the following:
>
> error.m:037: In clause for `m(in(error:val_closure((error:closure_list))), out((error:closure_list)))':
> error.m:037:   in argument 1 of call to predicate `error:eval/2':
> error.m:037:   mode error: variable `CCL' has instantiatedness `bound(error:val_closure((pred((free -> bound(error:list(ground, ...) ; (error:nil)))) is det)))',
> error.m:037:   expected instantiatedness was `bound(error:val_closure((pred((free -> bound(list(ground, bound(val_closure((pred(builtin:out(bound(list(ground, ...) ; nil))) is det)))) ; nil))) is det)))'.
>
> Now, if you read this error message very carefully, you may notice
> that "val_closure" occurs twice in the second inst -- but it is only
> module-qualified the first time that it occurs!  The expected inst
> for the inner bit ("...") is "bound(val_closure)", but actual inst
> for that part is "bound(error:val_closure)".
>
> This error message is still admittedly not very clear,
> but it is at least a small improvement ;-)

Thanks a lot for your clarification.
Would it be possible for the compiler to infer the right module qualifiers
from the fact that there are no other types with those functors in scope?

Tom


--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list