[mercury-users] type class bug?
Nicholas Nethercote
njn at csse.unimelb.edu.au
Thu Jun 22 12:16:25 AEST 2006
Hi,
I'm trying to use a type class.
I have these declarations:
:- typeclass pstr(T) where [ func pstr(T) = string ].
:- instance pstr(raw_item) where [ func(pstr/1) is pstr_raw_item ].
:- instance pstr(type_expr) where [ func(pstr/1) is pstr_type_expr ].
%:- instance pstr(expr) where [ func(pstr/1) is pstr_expr ].
This compiles fine.
If I uncomment the last line, I get this error:
Mercury/cs/zinc.c:1144: error: redefinition of 'mercury_data_base_typeclass_info_zinc__pstr__arity1__pair__pair__arity2__'
Mercury/cs/zinc.c:1135: error: previous definition of 'mercury_data_base_typeclass_info_zinc__pstr__arity1__pair__pair__arity2__' was here
In the zinc.c file the offending duplicate code looks like this:
const MR_BaseTypeclassInfo
mercury_data_base_typeclass_info_zinc__pstr__arity1__pair__pair__arity2__[] = {
(MR_Code *) 0,
(MR_Code *) 0,
(MR_Code *) 0,
(MR_Code *) 1,
(MR_Code *) 1,
MR_MAYBE_STATIC_CODE(MR_ENTRY_AP(fn__zinc__ClassMethod_for_zinc__pstr____pair__pair__arity2______zinc__pstr_1_1_0))
};
The types 'type_expr' and 'expr' look like this:
:- type type_expr == pair(raw_type_expr, src_locn).
:- type expr == pair(raw_expr, src_locn).
It seems like these are similar enough that Mercury gets confused.
Is this a bug? I'm using:
Mercury Compiler, version rotd-2006-05-26, configured for i686-pc-linux-gnu
Thanks.
Nick
--------------------------------------------------------------------------
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