pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

[Bug][CLI]: Match does not narrow based on length

Open yangdanny97 opened this issue 9 months ago • 1 comments

Describe the Bug

https://pyrefly.org/sandbox/?code=MQAg6gpgNgxg9gWwiALnVALZAFAngJwgDMpcQBlAQwDsATAIzgA8AaTASwGcQuRKQADpQDmEAFCgA7lkIhccAK4gYNEJPzsUENpwyVZNWiCgR91PowUpUuAe2rCe5vCgxxqAOgkSQACQgGBsqKAiYgRKYoCoTccEQc3JyGjEwAXD4AtCAA4hDWhJRQGSjsSDYCyDBYMADW9o4REAyUtZkgAKqcyIQAbqZQAPoothAAFACUqOj2nBUw1vYR+IRGwxWcbRBMFRpI1NaSmhiYyACSACIAouGR0RDcrpQHyJwKAgJw+NajEB7CHnwrHB4AhQnltCBhHBitDaMR7Jp2O42G4+vg2HkYOM2mANFo+HQQPgFM5cK53ME4SBaOxCPNSE45Ip8CB6Pg4JIuvgxER2QhyvUeKDPvkIH1CkMRmI4fEtJwUKM0qg3iYANr2FAAXRAAB9lWD1fs2BrNeN0iALSAEE8qiA0mJLY7lJQuiBVUR5ZrzU6fb1+pKKorsT6fQ6Q0A

Codebase

No response

Other Attempts

No response

yangdanny97 avatar May 12 '25 18:05 yangdanny97

There are two kinds we need to handle:

  • concrete pattern = exclude tuples that can;t be exactly this length
  • unbounded patterns = exclude tuples that have < n-1 elements

yangdanny97 avatar May 15 '25 02:05 yangdanny97

This is fixed and there's a regression test in the codebase.

https://github.com/facebook/pyrefly/blob/a92962ad0cdc819d5567dbf34b226309e259a6ef/pyrefly/lib/test/flow.rs#L827-L840

fangyi-zhou avatar Aug 21 '25 23:08 fangyi-zhou

Hurrah!

samwgoldman avatar Aug 21 '25 23:08 samwgoldman