-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Summary of issue:
Right now, which rewrite is applied to uses of the subscript operator depends on which interfaces are implemented for the types, see #2274 . There is a final blanket implementation to ensure that the two rewrites produce consistent answers with the same type. However, the category of the result, whether it is a value or a reference, depends on which rewrite is applied. In a generic context, it can be known that subscripting is implemented, and the type that will result, without knowing if it produces a reference expression.
Similarly, #3720 will apply a different rewrite for binding depending on the category of the input. The type of the answer is constrained to match, but different implementations would be used in the two cases.
This leaves two possibilities, neither of which are good:
- If the rewrite is done at type checking time based on how much we know about the type, then the same code can do different things in a generic context and a concrete context.
- If the rewrite is done as part of monomorphization, then we would always do the same thing but sometimes use an impl that wasn't part of the constraints on the generic.
Details:
Details with an example may be found here.
Any other information that you want to share?
This came up in these contexts: