E1123: role method implementation changes must_use

View source

When a role method carries meta must_use("reason"), every implementation must repeat the same contract.

When a role method carries meta must_use("reason"), every implementation must repeat the same contract. An implementation that leaves it out, or adds one that the role does not have, would change what a caller of the role has to do with the result (ADR-0090). The error points at the method in the perform block.

Example

actus
struct File {
    value: Int,
}

role Writer {
    meta must_use("check the count")
    verb write(abs self: File) -> Int;
}

perform Writer for File {
    verb write(abs self: File) -> Int {
        return self.value;
    }
}

verb main() {
}

Fix

Write the same must_use on the implementation.

actus
struct File {
    value: Int,
}

role Writer {
    meta must_use("check the count")
    verb write(abs self: File) -> Int;
}

perform Writer for File {
    meta must_use("check the count")
    verb write(abs self: File) -> Int {
        return self.value;
    }
}

verb main() {
}

Run actus explain E1123 in your terminal to read this entry offline. Browse Modules & rules or all error codes.