Skip to content

Track splatted variadic tuple shape during call matching - #4491

Open
alexander-beedie wants to merge 2 commits into
facebook:mainfrom
alexander-beedie:variadic-splat-star
Open

Track splatted variadic tuple shape during call matching#4491
alexander-beedie wants to merge 2 commits into
facebook:mainfrom
alexander-beedie:variadic-splat-star

Conversation

@alexander-beedie

@alexander-beedie alexander-beedie commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Overview

Calls to a function annotated *args: *tuple[*tuple[V, ...], S, S] were rejected, even when the arguments matched.

pyrefly already knows how to track positions through a splat, it just needed some additional wiring-up for CallArgPreEval::Star.

Solution

Give Star the same treatment Fixed already had; now carries the shape (prefix, middle, suffix) along with consumed, which has much the same role as Fixed's index. Note that it isn't exactly the same as a parameter consumes exactly one Fixed element, but a variadic parameter absorbs the remainder of a splat.

Fixes #4482.

Test Plan

All existing unit tests pass, and several new unit tests were added (including the one given in the original Issue, which has been added "as-is" 👍)

@meta-codesync

meta-codesync Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D115423717. (Because this pull request was imported automatically, there will not be any future comments.)

@github-actions

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pyrefly has deficiencies in parsing functions with *args: *tuple[*Ts, Suffix] annotation.

1 participant