Describe the Bug
def untyped_fallback(x): # deliberately unannotated
return x
def f(x: str | None) -> str:
if x is None:
y = untyped_fallback("default")
print(y.upper())
x = y
print(x.upper())
return x.upper()
ERROR sandbox.py:10:15-22: Object of class `NoneType` has no attribute `upper` [[missing-attribute](https://pyrefly.org/en/docs/error-kinds/#missing-attribute)]
ERROR sandbox.py:11:12-19: Object of class `NoneType` has no attribute `upper` [[missing-attribute](https://pyrefly.org/en/docs/error-kinds/#missing-attribute)]
Here, y is Unknown, as untyped_fallback. So y.upper() isn't flagged. What's surprising to me is that then, after x=y, x.upper() is flagged, saying that None doesn't have an upper attribute
No other type checker I tried reports on this
Spotted in Hypothesis
Sandbox Link
https://pyrefly.org/sandbox/?project=v2.pZRNDoIwEIWv0sgCXEj3nMIDkJgKFY2kEKCmvb1vBhr5UTYu275OpvO-vl-RSRZaQ5lSXm54-VUVz8QdMyEi2IvPSaGhaw-RooaxQATMsHHk1AR04vhjTggzFFh-wHVfoPV47qaBnPpSth7yAywO0tF3n9q21V1ynJ04FPFroVsJQ8Nhe2tsJM7jhphmhEgDEZXFDOB0mpsImanFfRjaPpMyXG-6Smojy6bo5eKGFMSweqkHx_GynGgYxB5l_yEqHoGK93iKCSdWnJTxEPEksM_FcbDLzhs
(Only applicable for extension issues) IDE Information
No response
Describe the Bug
Here,
yisUnknown, asuntyped_fallback. Soy.upper()isn't flagged. What's surprising to me is that then, afterx=y,x.upper()is flagged, saying thatNonedoesn't have anupperattributeNo other type checker I tried reports on this
Spotted in Hypothesis
Sandbox Link
https://pyrefly.org/sandbox/?project=v2.pZRNDoIwEIWv0sgCXEj3nMIDkJgKFY2kEKCmvb1vBhr5UTYu275OpvO-vl-RSRZaQ5lSXm54-VUVz8QdMyEi2IvPSaGhaw-RooaxQATMsHHk1AR04vhjTggzFFh-wHVfoPV47qaBnPpSth7yAywO0tF3n9q21V1ynJ04FPFroVsJQ8Nhe2tsJM7jhphmhEgDEZXFDOB0mpsImanFfRjaPpMyXG-6Smojy6bo5eKGFMSweqkHx_GynGgYxB5l_yEqHoGK93iKCSdWnJTxEPEksM_FcbDLzhs
(Only applicable for extension issues) IDE Information
No response