E1056: unknown role

View source

A perform declaration and a role bound such as T: Reader must name a role that is declared with role (ADR-0014).

A perform declaration and a role bound such as T: Reader must name a role that is declared with role (ADR-0014). The error points at the perform declaration or at the bound that names the missing role. A dynamic parameter that names an unknown role is a separate error, E1099.

Example

actus
struct Cursor {
    position: Int,
}

perform Reader for Cursor {
    verb read(abs self: Cursor) -> Int {
        return 0;
    }
}

verb main() {
}
actus
verb pull[T: Reader](erg value: T) -> Int {
    return 0;
}

verb main() {
}

Fix

Declare the role before it is used, or correct the name.

actus
struct Cursor {
    position: Int,
}

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

perform Reader for Cursor {
    verb read(abs self: Cursor) -> Int {
        return 0;
    }
}

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

verb pull[T: Reader](erg value: T) -> Int {
    return 0;
}

verb main() {
}

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