Skip to content

When generating superclass instances, C2HS incorrect emits method names from the terminal class #21

@ian-ross

Description

@ian-ross

Bug imported from C2HS Trac

Trac ticket created: 2009-08-09T17:23:53-0700; last modified: 2009-08-09T17:25:16-0700


When processing this kind of class hook (example from tests/system/Pointer.chs):

-- test classes
{#pointer *Point as APoint newtype#}
{#class APointClass APoint#}

{#pointer *ColourPoint as AColourPoint newtype#}
{#class APointClass => AColourPointClass AColourPoint#}

C2HS generates an incorrect superclass instance:

class APointClass p => AColourPointClass p where
aColourPoint :: p -> AColourPoint
fromAColourPoint :: AColourPoint -> p
instance APointClass AColourPoint where
aColourPoint (AColourPoint p) = AColourPoint (castPtr p)
fromAColourPoint (AColourPoint p) = AColourPoint (castPtr p)
instance AColourPointClass AColourPoint where
aColourPoint = id
fromAColourPoint = id

The instance of APointClass should have methods aPoint and fromAPoint, not aColourPoint and fromAColourPoint.

The bug is due to a typo in C2HS.Gen.Bind where typeIde is named but typeIde' should have been (see patch)

I tried doing darcs send but the message didn't appear on the mailing list, sorry for the doubling if it does show up.

This applies to version 0.16.0, which does not have an entry in the trac dropdown.


Original Trac ticket had attachments:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions