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
Pyrefly doesn't fully narrow tuple in exhaustible match-case #5206
Which seems exhaustive to me? When I reduced it I found the smaller example, let me know if I should file this as a separate issue. I'm not sure about the semantics of a wildcard here
I tried avoiding wildcards but got something similar, let me know if this should be a separate issue. It does seem related to how narrowing works for tuples though. Also it works differently in the sandbox versus my local install (v1.3.2), it differs in pick2.
fromtypingimportassert_neverclassA: ...
defpick(left: A|None, right: A|None) ->A: # ERROR sandbox.py:4:46-47: Function declared to return `A`, but one or more paths are missing an explicit `return` [bad-return]matchleft, right:
caseNone, None:
returnA()
caseNone, A():
returnrightcaseA(), None:
returnleft# However it correctly asserts it to never (in sandbox, not in locally installed version v1.3.2)defpick2(left: A|None, right: A|None) ->A:
matchleft, right:
caseNone, None:
returnA()
caseNone, A():
returnrightcaseA(), None:
returnleftcaseA(), A():
returnrightcasewildcard:
assert_never(wildcard) # Works in sandbox, not in v1.3.2# Looks to be related to tuples, this works fineclassB: ...
defpick(left: A|B) ->A|B:
matchleft:
caseA():
returnleftcaseB():
returnleft
Looks like the original two examples work in the sandbox now, but #5206 (comment) and the pick example are still broken:
class A: ...
def pick(left: A | None, right: A | None) -> A: # ERROR sandbox.py:4:46-47: Function declared to return `A`, but one or more paths are missing an explicit `return` [bad-return]
match left, right:
case None, None:
return A()
case None, A():
return right
case A(), None:
return left
case A(), A():
return right
Activity
StefanBRas commentedon Oct 13, 2026
I tried avoiding wildcards but got something similar, let me know if this should be a separate issue. It does seem related to how narrowing works for tuples though. Also it works differently in the sandbox versus my local install (v1.3.2), it differs in
pick2.sandbox: https://pyrefly.org/sandbox/?project=v2.1VZPT4MwFP8qL-GwmUyIk2jCjSUaDyaaXTx4gUEFMrYu0G367f29lmYMkGxHb9D09bW_f-0VkdmOJOulMCDXda1yd0WynpbiSwUUNnpFPBVZ3hrQkkCZQ0_L5duSTl0DP_Afbv3HgJ4bB0BIaAMUSEkrxyiMZrTaIy9gBghhA9B0YNTwkKBNUUPXGcVbEt-7skigt8iURvS5ilMgyz9gwohKJTnxlu1GT_JGzormDB1DtdwRsiQHKjA-XKC7dEoweawHb48hduhFHhl9qB6hWrF6yp-GFwSzYpg0PTSFNRpkZwQ9sVVKmbCE8QnbI5FTsko93Ln37lx7y9I4v5DHfwdjv-KqHseiTJO4SjsVbW9M7ZwbiPxDVmtQ02fDYG5ofZUSk0DeSqB3GSMc-E_tcU3hflU5Mv2oF0IM6bvGuG_RuG_AewvDD3_1OOqS8ycAA4gtxub2I9GhdzNgzw_dIkuzPZ4cUB727uC1IShXalcHnmfLZZV5YuulMqm9swqPOP3jQ1zoh8z5ciR1hNdYdjiL_YuyeGKieDKWxBMOYswYDddf
rchen152 commentedon Nov 13, 2026
Related:
rchen152 commentedon Nov 13, 2026
Looks like the original two examples work in the sandbox now, but #5206 (comment) and the
pickexample are still broken: