Skip to content

Recognize match pattern captures as assignments - #865

Open
yangfan-yf-yf wants to merge 1 commit into
python-rope:masterfrom
yangfan-yf-yf:fix/match-case-bindings-861
Open

Recognize match pattern captures as assignments#865
yangfan-yf-yf wants to merge 1 commit into
python-rope:masterfrom
yangfan-yf-yf:fix/match-case-bindings-861

Conversation

@yangfan-yf-yf

Copy link
Copy Markdown
Contributor

Description

Pattern capture names on MatchAs, MatchStar, and MatchMapping are string fields, so the scope visitor did not register them as assignments. Rename consequently rejected those names as unresolved. Inline could also replace a capture with a value pattern, changing program semantics.

This registers the three capture forms in their enclosing scope, returns a conservative unknown inference result for pattern assignments, and rejects inline whenever the selected name has a pattern-capture assignment. Rename now updates both capture definitions and references.

Fixes #861

Checklist

  • I have added tests that prove the fix is effective
  • I have updated CHANGELOG.md

Validation

  • Full suite: 2121 passed, 12 skipped, 5 xfailed
  • Relevant selection: 442 passed, 10 skipped
  • All configured pre-commit checks for the changed Python files pass
  • git diff origin/master...HEAD --check passes

@yangfan-yf-yf
yangfan-yf-yf marked this pull request as ready for review August 26, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename and inline refactor did not recognize match-cases statements as variable assignment

1 participant