E1060: role method has no explicit receiver

View source

Every method of a role names its receiver as the first parameter, called self, and the role of that parameter is part of the contract (ADR-0014).

Every method of a role names its receiver as the first parameter, called self, and the role of that parameter is part of the contract (ADR-0014). The compiler rejects a method that has no parameters or whose first parameter has another name. It also rejects a parameter of type Self that is not the first one. The message names the method and the role. The error points at the method or at the misplaced parameter.

Example

actus
struct Cursor {
    position: Int,
}

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

verb main() {
}
actus
role Reader {
    verb read() -> Int;
}

verb main() {
}

Fix

Make self the first parameter and give it the ownership role that the method needs.

actus
struct Cursor {
    position: Int,
}

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

verb main() {
}

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