E1136: role method implementation drops deterministic

View source

When a role method is marked meta deterministic, every implementation must be marked too.

When a role method is marked meta deterministic, every implementation must be marked too. A caller of the role relies on the promise, and an implementation without it would break the promise behind the role (ADR-0100). The error points at the method in the perform block. Moving a field out of a zero_on_drop owner is a different error, E1145.

Example

actus
struct File {
    value: Int,
}

role Writer {
    meta deterministic
    verb write(abs self: File) -> Int;
}

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

verb main() {
}

Fix

Mark the implementation meta deterministic.

actus
struct File {
    value: Int,
}

role Writer {
    meta deterministic
    verb write(abs self: File) -> Int;
}

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

verb main() {
}

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