pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

Compound `if` expressions appear to be resolved backwards when checking dict contents

Open bigfootjon opened this issue 6 months ago • 1 comments

Describe the Bug

See the sandbox, pyrefly is inferring a type as a literal when the if statement checks the exact opposite of that.

Note that removing the not does nothing which suggests that the not is not being considered when specializing the type

Sandbox Link

https://pyrefly.org/sandbox/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoCGAzkQKZ4D68CpAULcGGAFxQAmSAxjANpEwgANFH4gAulAC8UAN4BfekmBQARIzArMKKOsIo2OpjzVMVEpESgow+FcRXNaUZ1ABuBADZTDYY+rNOLsRklNSkABTuHsKiAJRAA

(Only applicable for extension issues) IDE Information

No response

bigfootjon avatar May 17 '25 20:05 bigfootjon

Interesting, I think strings are supposed to be compared by equality instead of is, but != and is not both behave incorrectly here. Thanks for flagging.

yangdanny97 avatar May 18 '25 02:05 yangdanny97

Hm, somehow this no longer repros so I guess it was fixed as a byproduct of something else that landed this week. I'll add a test case to make sure it doesn't regress.

yangdanny97 avatar May 28 '25 13:05 yangdanny97