16727, “lydia-duncan”, “Should operators be treated like methods when listing an involved type in a limitation clause?”, “2020-11-17T18:34:21Z”
This issue relates to #16725
We’ve decided that listing a type in a use or import statement’s limitation clause (e.g. use M only MyType;
, import M.MyType
) impacts methods on that type visible in the scope that is being used or imported. Operators are (currently) defined as stand-alone functions that take instances of types as arguments - however, their functionality is frequently important to a type’s behavior, and we don’t support listing operator names in limitation clauses. That means that in order to bring in operators defined in a scope, the user must have a more permissive use statement than they might otherwise desire (e.g. use M;
, bringing in everything defined in M).
We don’t expect to allow listing operators specifically in limitation clauses, as the user is more likely to care about the operator because they care about the types it operates on. But should listing the type bring in these operators as well?
If in #16725, we decide that operators should also resolve by searching the scope where their argument types are defined, this will probably handle most cases. One could argue that deciding to do both would be consistent. One could also argue that allowing operators to be brought in this way could be considered a form of hijacking, especially in the case where there are not otherwise methods in that scope