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
A walrus if test is never settled, so its unreachable suite is not reported #5499
Pyrefly reports a suite as unreachable when its if test is always false (or the else suite when the test is always true). It does not do this when the test is a walrus (x := value).
fromtypingimportLiteraldeffalsy(value: Literal[False]) ->None:
ifvalue:
print(1) # This code is unreachableifx:=value:
print(2) # no errordeftruthy(value: Literal[True]) ->None:
ifx:=value:
print(3)
else:
print(4) # no errorclassAlwaysFalse:
def__bool__(self) ->Literal[False]:
returnFalsedefuser_defined(a: AlwaysFalse|None) ->None:
ifaand (b:=a):
print(5) # This code is unreachableifb:= (aanda):
print(6) # no error
Expected behavior
print(2), print(4) and print(6) are reported as unreachable.
Cause
declared_bool_value (pyrefly/lib/alt/solve.rs) computes the declared truth value of a branch test. It has no case for Expr::Named, so a walrus test falls to _ => None.
Activity
rchen152 commentedon Nov 3, 2026
Fixed by #5497