E1037: invalid receiver for a method

View source

A verb is a method only when its first parameter is named self and has the type of a declared struct (ADR-0029).

A verb is a method only when its first parameter is named self and has the type of a declared struct (ADR-0029). A self parameter of another type, such as Int, can never be the receiver of a call, so the declaration is rejected. The error points at the self parameter.

Example

actus
verb double(abs self: Int) -> Int {
    return 1;
}

verb main() {
}

Fix

Give self the type of a struct, or rename the parameter if the verb is not meant to be a method.

actus
struct Counter {
    n: Int,
}

verb double(abs self: Counter) -> Int {
    return 2;
}

verb main() {
}

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