E1153: call that more than one verb or role method takes

View source

A call name(self: ROLE x, ...) names the verb or role method called by its name and by the type of the self argument (REQ-TYPE-0012).

A call name(self: ROLE x, ...) names the verb or role method called by its name and by the type of the self argument (REQ-TYPE-0012). The call is ambiguous when more than one candidate has that name and takes that type: a verb and the method of a role that the type performs, two roles that the type performs with a method of the same name, or two roles that bound a generic receiver with a method of the same name. The compiler does not choose one. The message lists every candidate, the verb or the role with its perform, and the error points at the call.

Example

actus
struct Counter {
    value: Int,
}

role Bumper {
    verb bump(ins self: Counter) -> Int;
}

perform Bumper for Counter {
    verb bump(ins self: Counter) -> Int {
        self.value = self.value + 1;
        return self.value;
    }
}

verb bump(ins self: Counter) -> Int {
    return 0;
}

verb main() -> Int {
    erg counter = Counter { value: 1, };
    return bump(self: ins counter);
}

Fix

The language has no spelling that picks one candidate at a call: the call names the verb and the type of self only. Rename one of the candidates so that the name is unique for that type.

actus
struct Counter {
    value: Int,
}

role Bumper {
    verb bump(ins self: Counter) -> Int;
}

perform Bumper for Counter {
    verb bump(ins self: Counter) -> Int {
        self.value = self.value + 1;
        return self.value;
    }
}

verb reset(ins self: Counter) -> Int {
    return 0;
}

verb main() -> Int {
    erg counter = Counter { value: 1, };
    return bump(self: ins counter);
}

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