CustomStringConvertible does not work in Toffee v2

CustomStringConvertible does not seem to work in Toffee v2 projects. For example,

public struct FailingDescription: CustomStringConvertible {
    public var description: String {
        return "foo"
    }
}

fails with

E: Internal error: Duplicate method with mismatching signature: mi_t23_DeviceTest2020_d_FailingDescription10_get__description
   (0,0): duplicate-error E0: Internal error: Duplicate method with mismatching signature: mi_t23_DeviceTest2020_d_FailingDescription10_get__description

Curious. Definitely compiler bug, given its an Internal Error.

Thanks, logged as bugs://84363

Note that in v1 it give some “hides a method from the parent class”, due to the missing “override” (since “description” is defined NSObject). tis probably is related somehow.

Indeed. The following compiles, but the text representation of FailingDescription does not work:

public struct FailingDescription: CustomStringConvertible {
    override public var description: NativeString! {
        return "foo"
    }
}

Hmm, what does it do?

E: Type mismatch, cannot assign "<type reference>" to "Object"

But thats a compiler error? you said it compiles, but doesn’t work? Or am I misunderstanding?

Ah, this happens when I try to use FailingDescription as a String. If I don’t use it, the code compiles fine. Calling description explicitly gives E: Cannot access non-static member "description" on type "FailingDescription", but that can easily be fixed by adding static in the declaration. It doesn’t fix the type mismatch, though.

descrription is an instance method of course, the error sounds like you’re calling it on the class, not an instance?

ie

FailingDescription.description

vs

let x = FailingDescription()
x.description

?

Obviously… :man_facepalming:

So yes, calling description explicitly works, but it doesn’t get called implicitly when a String is needed. What I get is a pointer description instead. As a side note, in Apple’s compiler specifying override in anything but class members is an error.