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

peter at hawkins.emu.id.au peter at hawkins.emu.id.au
Mon Apr 5 22:04:31 AEST 2004


I don't know whether this is a bug or by design (if so, it's not very

Consider two modules:

:- module test.

:- interface.
:- import_module io.
:- pred main(io.state, io.state).
:- mode main(di, uo) is det.

:- implementation.
:- import_module test2.

main(!IO) :-
    X = test2.foo_init,
    Y = to_int(X),
    io.print("Hi there!\n", !IO).

:- module test2.

:- interface.
:- import_module int.

:- typeclass foo(T) where [
    func to_int(T) = int

:- type foo_instance ---> bar.

:- instance foo(foo_instance).

:- func foo_init = foo_instance.

:- implementation.

foo_init = bar.

(ie. foo only has an abstract instance declaration, with no

Then running mmake test:
hawkinsp at vice:~/tmp/bug2$ mmake test
mmc --compile-to-c --grade asm_fast.gc          test > test.err 2>&1
mmc --compile-to-c --grade asm_fast.gc          test2 > test2.err 2>&1
mgnuc --grade asm_fast.gc        --      -c test.c -o test.o
mgnuc --grade asm_fast.gc        --      -c test2.c -o test2.o
mgnuc --grade asm_fast.gc        --      -c test_init.c -o test_init.o
ml --grade asm_fast.gc              --    -o test test_init.o \
        test.o test2.o \

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?


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