Skip to content

Reject multiple starred names in sequence patterns - #25976

Merged
charliermarsh merged 2 commits into
mainfrom
charlie/fix-multiple-starred-sequence-patterns
Jun 14, 2026
Merged

Reject multiple starred names in sequence patterns#25976
charliermarsh merged 2 commits into
mainfrom
charlie/fix-multiple-starred-sequence-patterns

Conversation

@charliermarsh

Copy link
Copy Markdown
Member

Summary

Python permits at most one starred name in a sequence pattern, but our parser currently accepts multiple:

match value:
    case [*head, middle, *tail]:
        pass

This tracks whether a sequence pattern already contains a star and reports invalid-syntax on each later starred name. The diagnostic points to the additional starred pattern and uses CPython's error message, while keeping the recovered AST available to downstream tools.

@astral-sh-bot

astral-sh-bot Bot commented Jun 14, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented Jun 14, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@astral-sh-bot

astral-sh-bot Bot commented Jun 14, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@charliermarsh charliermarsh added the parser Related to the parser label Jun 14, 2026
@charliermarsh
charliermarsh requested a review from ntBre June 14, 2026 14:03
@charliermarsh
charliermarsh marked this pull request as ready for review June 14, 2026 14:03
@charliermarsh
charliermarsh merged commit ded6c00 into main Jun 14, 2026
58 checks passed
@charliermarsh
charliermarsh deleted the charlie/fix-multiple-starred-sequence-patterns branch June 14, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parser Related to the parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant