pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

fix Contextual typing works only with the first element in a union #793

Open asukaminato0721 opened this issue 1 month ago • 2 comments

fix #793

Added collect_var_from_hint/hint_from_types to gather element candidates across union branches and reused them in the container decomposers to keep contextual hints from collapsing to the first branch

Taught list inference to try each union branch with its own hint before falling back, plus factored the existing logic into a reusable helper

Unblocked the regression test by removing the expected errors and bug marker now that the behavior is fixed

asukaminato0721 avatar Oct 26 '25 10:10 asukaminato0721

cc @samwgoldman @grievejia for review

yangdanny97 avatar Nov 13 '25 15:11 yangdanny97

@stroxler has imported this pull request. If you are a Meta employee, you can view this in D87788142.

meta-codesync[bot] avatar Nov 24 '25 16:11 meta-codesync[bot]