You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False positive Case pattern can never match when matching union against protocol #5059
When matching a union type against a Protocol, pyrefly incorrectly thinks matching is impossible.
The warning doesn't get triggered when a non-union type is used.
fromtypingimportProtocol, runtime_checkable@runtime_checkableclassSupportsMethod(Protocol):
defmethod(self) ->None: ...
classFoo: ...
defcheck(arg: Foo) ->None:
matcharg:
caseSupportsMethod(): # OKpassdefcheck_union(arg: Foo|None) ->None:
matcharg:
caseSupportsMethod(): # WARNING: case pattern can never matchpass
WARN sandbox.py:17:9-18:17: Case pattern can never match subject of type `Foo | None` [unreachable-match-case]
Activity
shahhamdihassan commentedon Oct 23, 2026
Thanks for the report! This reproduces on 1.4.0, and None isn't needed to trigger it (Foo | Bar does too): https://pyrefly.org/sandbox/?project=v2.xVVLboMwEL3KSNmURTgAq6qVssuqB0AuGGw1sRHYaqVevvM8DlAaVVlECuxseWae38fft0fmEmmdZOQYXbDMWGN084EwATls0yvr4ry3OKDSdBSHXAoW1VXzLOKhsiylttQ5eP9n7UWNq7XnNOLcl_NRt6ttdGL59yf9lAzKBbdSPavQmGTfRfCcvHoLoqiIdqS_BliR3Oyxyycqw7-jg2ID0eAnCzYqUjTFdxnRdxiCOzhcg2Wj55soShk34l2oP20wNZrMc-dcuM_40bFJGgPO9qnCHmduBcRp51pJKQ4hVjE5rVvdUvAURtv3Gr79hcd3dX5X1oCYy8fgefUjLElwGcujysoBnCSoBNAogNvyk_YFjEDJRx9Dz7-e_wE
We'll follow up here once we have a fix.
github-actions commentedon Nov 7, 2026
This issue has someone assigned, but has not had recent activity for more than 2 weeks.
If you are still working on this issue, please add a comment so everyone knows. Otherwise, please comment
#unclaimto unassign yourself.Thank you for your contributions!
shahhamdihassan commentedon Nov 9, 2026
Still on this one. The fix is written and waiting for review on our side. I'll post here once it lands.