E1133: role method implementation adds a capability

View source

A role method lists the capabilities that its implementations may need.

A role method lists the capabilities that its implementations may need. A perform block may use fewer, but not more, so a call through the role cannot hide a platform requirement (ADR-0096). The error points at the method in the perform block.

Example

actus
struct File {
    value: Int,
}

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

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

verb main() {
}
toml
[package]
name = "example"
version = "0.1.0"
edition = "alpha"
entry = "main"

[build]
target = "x86_64-unknown-linux-gnu"
profile = "debug"
runtime = "std"

Fix

Declare the capability on the role method.

actus
struct File {
    value: Int,
}

role Writer {
    meta capability("posix.cloexec")
    verb write(abs self: File) -> Int;
}

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

verb main() {
}
toml
[package]
name = "example"
version = "0.1.0"
edition = "alpha"
entry = "main"

[build]
target = "x86_64-unknown-linux-gnu"
profile = "debug"
runtime = "std"

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