Skip to content

feat: structural match patterns - #63

Merged
SizzleUnrlsd merged 2 commits into
mainfrom
feat/match-patterns
Sep 4, 2026
Merged

SizzleUnrlsd merged 2 commits into
mainfrom
feat/match-patterns

Conversation

@SizzleUnrlsd

Copy link
Copy Markdown
Contributor

Summary

Last point of the consolidation: sequence, mapping and class patterns in match.

  • Tests first (test: define sequence, mapping and class patterns), implementation follows.
  • The HIR represents them (SequencePattern with StarPattern, MappingPattern with a **rest, ClassPattern with keyword sub-patterns); scopes bind their captures as locals.
  • The CFG builder, which already lays a match out as an if chain over a hidden subject, desugars them faithfully: a sequence pattern tests the length, exactly or at least when a star is present, applies its sub-patterns to indexed items and binds the star to the middle slice; a mapping pattern tests each key's membership and applies sub-patterns to the values, **rest binding the subject; a class pattern tests isinstance and applies keyword sub-patterns to attributes. Every sub-pattern applies to the expression so built, so patterns nest, guards see the captures and taint flows through them like through any assignment. Positional class patterns need the class's __match_args__ and stay reported per function.
  • The existing test that used a sequence pattern as its unsupported example now uses a positional class pattern.

On the sixteen repositories nothing changes. This closes the consolidation list agreed after the roadmap: closure bodies, self state across methods and structural patterns are all in.

@SizzleUnrlsd SizzleUnrlsd self-assigned this Sep 4, 2026
@SizzleUnrlsd
SizzleUnrlsd merged commit 7e869b5 into main Sep 4, 2026
6 checks passed
@SizzleUnrlsd
SizzleUnrlsd deleted the feat/match-patterns branch September 4, 2026 15:34
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.

1 participant