E1058: performance misses a method of its role

View source

perform Role for Type is the realization of a role (ADR-0014), so it must define every method that the role declares.

perform Role for Type is the realization of a role (ADR-0014), so it must define every method that the role declares. A missing method would leave a call through the role without a body. The message names the role and the missing method. The error points at the perform declaration. A perform Drop for block needs its drop method in the same way.

Example

actus
struct Cursor {
    position: Int,
}

role Reader {
    verb read(abs self: Cursor) -> Int;
    verb peek(abs self: Cursor) -> Int;
}

perform Reader for Cursor {
    verb read(abs self: Cursor) -> Int {
        return 0;
    }
}

verb main() {
}

Fix

Define every method of the role in the perform block.

actus
struct Cursor {
    position: Int,
}

role Reader {
    verb read(abs self: Cursor) -> Int;
    verb peek(abs self: Cursor) -> Int;
}

perform Reader for Cursor {
    verb read(abs self: Cursor) -> Int {
        return 0;
    }

    verb peek(abs self: Cursor) -> Int {
        return 1;
    }
}

verb main() {
}

Run actus explain E1058 in your terminal to read this entry offline. Browse Ownership & types or all error codes.