[mercury-users] Bug in mercury type class checks?

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Apr 6 13:51:42 AEST 2004

On 05-Apr-2004, peter at hawkins.emu.id.au <peter at hawkins.emu.id.au> wrote:
> I don't know whether this is a bug or by design (if so, it's not very
> friendly).
> (ie. foo only has an abstract instance declaration, with no
> implementation)
> test.o(.rodata+0x0): undefined reference to `mercury_data_base_typeclass_info_test2__foo__arity1__test2__foo_instance__arity0__'
> collect2: ld returned 1 exit status
> gmake: *** [test] Error 1
> Shouldn't that have been caught by mercury before the linking stage?

Ideally yes.

This is a quality-of-implementation issue rather than a bug as such.
A good quality implementation should diagnose errors as soon as possible,
and should issue error messages in terms that are meaningful to the user.
The latter is more important than the former.

Versions 0.11 of the Mercury compiler issues reasonable error messages
for this sort of thing, of the form

	test.o(.rodata+0x0): undefined reference to `<instance declaration for test2:foo(test2:foo_instance/0)>'

Unfortunately, however, there is no test for this in the test suite, and
the demangling of instance declarations has been broken in the current
CVS and release-of-the-day distributions.

It's pretty simple to fix the demangler -- the difference is just that
the new compiler outputs "mercury_data_base_typeclass_info_..."
instead of "mercury_data___base_typeclass_info_...".

Issuing the error message at compile time rather than link time would
also be a good idea, but it is something that we have not yet gotten
around to.  As always, volunteers are welcome :)

Fergus Henderson                    |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
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