feat: implement structured pattern matching with nested constructor support#275
Open
metalurgical wants to merge 1 commit intoBlockstreamResearch:masterfrom
Open
feat: implement structured pattern matching with nested constructor support#275metalurgical wants to merge 1 commit intoBlockstreamResearch:masterfrom
metalurgical wants to merge 1 commit intoBlockstreamResearch:masterfrom
Conversation
…upport Introduce a full pattern matching pipeline for match expressions, including typed pattern representation, validation, and a structured decision tree. This establishes a foundation for deterministic and type-safe match evaluation, enabling correct handling of nested patterns and complex destructuring. Additionally extract tests for parse to new file to reduce file bloat and improve maintainability
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce a full pattern matching pipeline for match expressions, including typed pattern representation, validation, and a structured decision tree.
This establishes a foundation for deterministic and type-safe match evaluation, enabling correct handling of nested patterns and complex destructuring.
Additionally extract tests for parse to new file to reduce file bloat and improve maintainability.
Overview Diagram
flowchart TD A["match syntax"] --> B{"Old vs New"} B -->|Old| C["2 arms only → normalize"] B -->|New| D["multiple arms → analyze → validate → compile"] C --> E["Match.left/right"] D --> EExpanded Diagram
flowchart TD A["match syntax"] --> B{"Old vs New"} B -->|Old| C1["exactly 2 arms required"] C1 --> C2["classify arm pair"] C2 --> C3["Left/Right or None/Some or False/True"] C3 --> E["Match.left/right"] B -->|New| D1["parse multiple arms"] D1 --> D2["convert to structured pattern representation"] D2 --> D3["assign types to patterns"] D3 --> D4["ensure all arms use the same match kind"] D4 --> D5["check for duplicate arms"] D5 --> D6["check for overlapping patterns"] D6 --> D7["check for unreachable arms"] D7 --> D8["check exhaustiveness"] D8 --> D9["build decision tree"] D9 --> D10["convert back to two-arm form"] D10 --> E["Match.left/right"]