E1059: method does not match its role

View source

A method in a perform block must have the signature that the role declares (ADR-0014): the same parameter names, ownership roles and types, the same receiver and the same return...

A method in a perform block must have the signature that the role declares (ADR-0014): the same parameter names, ownership roles and types, the same receiver and the same return type. The message names the method and the role. The error points at the method. A perform Drop for block has one fixed shape, verb drop(ins self: T) without a return value, and any other shape is reported here too. Effects, capabilities, realtime, deterministic and must_use that differ from the role have their own codes.

Example

actus
struct Cursor {
    position: Int,
}

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

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

verb main() {
}
actus
struct Cursor {
    position: Int,
}

perform Drop for Cursor {
    verb drop(abs self: Cursor) {
    }
}

verb main() {
}

Fix

Write the method with the signature of the role. A drop method takes its value as ins self.

actus
struct Cursor {
    position: Int,
}

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

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

verb main() {
}
actus
struct Cursor {
    position: Int,
}

perform Drop for Cursor {
    verb drop(ins self: Cursor) {
    }
}

verb main() {
}

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