Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 87.94%. The percentage of expected errors that received a diagnostic held steady at 83.36%. The number of fully passing files held steady at 79/133. |
Memory usage reportMemory usage unchanged ✅ |
|
50d382d to
19addde
Compare
19addde to
5b2f0cc
Compare
| | | | ||
| | Declared type | ||
| | | ||
| info: no element of intersection `HasBar & HasNeither` is assignable to `SupportsFooAndBar` |
There was a problem hiding this comment.
hmmm... when Protocol types are involved, I don't think it's necessarily true that at least one element of the intersection type must be assignable to the declared type. E.g. this feels like it should be fine?
from typing import Protocol, runtime_checkable
@runtime_checkable
class Foo(Protocol):
def foo(self): ...
class Bar(Protocol):
def bar(self): ...
class FooAndBar(Foo, Bar, Protocol): ...
def f(x: Bar):
if isinstance(x, Foo):
reveal_type(x) # Bar & Foo
y: FooAndBar = xalthough... we currently emit a diagnostic on the last line there 🙈 not sure why yet https://play.ty.dev/3d1b9f3f-cbf9-423f-9c0c-495550da8d57
There was a problem hiding this comment.
not sure why yet
Isn't that the expected behavior based on our implementation of type relations for intersections, which (for assignability from an intersection) is precisely "break it apart and require at least one element to be assignable to the target"?
I don't disagree that Foo & Bar should be assignable to FooAndBar, but to support that we would need to add a new relation arm for intersection vs protocol that is higher priority than the main intersection arm.
There was a problem hiding this comment.
but to support that we would need to add a new relation arm for intersection vs protocol that is higher priority than the main intersection arm.
Right, or just move the existing "anything vs a protocol" arm higher in relation.rs? I can experiment tomorrow
Summary
This implementation is basically the dual of what we do for unions (with the assignability direction flipped).
Test Plan
Updated mdtests.