-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Bug description
Actual behavior
Implement __contains__(self, read other: Self) -> Bool
on my struct and get an error about not implementing EqualityComparable & Movable & Copyinit
.
Expected behavior
I should be able to see what the expected signature of __contains__
is in documentation somewhere. (And all special methods).
Steps to reproduce
I was answering this question on the forum and ran into an awkward case that could maybe use more clarity in the official docs (or I just couldn't find it).
The user had implemented __contains__
, but Self didn't implement EqualityComparable
. The compiler error message did give a helpful-ish error message about Self not implementing that when it couldn't satisfy __contains__
.
How are people supposed to know the expected signature of the special methods? All the docs say is that they roughly match Python. I've just gotten used to looking for examples in stdlib for most things, but that's likely not the optimal method.
Is the goal to migrate those special methods to traits at some future point? Is there a proposal that covers that already? This seems to be a relevant issue: #2924, which is postponed.
Another way to solve this would be to publish docs for all the special methods until the trait situation for them is decided.
System information
Mojo v0.25.3