Skip to content

feat: implement structured pattern matching with nested constructor support#275

Open
metalurgical wants to merge 1 commit intoBlockstreamResearch:masterfrom
metalurgical:issue_250
Open

feat: implement structured pattern matching with nested constructor support#275
metalurgical wants to merge 1 commit intoBlockstreamResearch:masterfrom
metalurgical:issue_250

Conversation

@metalurgical
Copy link
Copy Markdown
Contributor

@metalurgical metalurgical commented Apr 6, 2026

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 --> E
Loading

Expanded 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"]
Loading

…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
@metalurgical metalurgical requested a review from delta1 as a code owner April 6, 2026 14:00
@metalurgical
Copy link
Copy Markdown
Contributor Author

Resolves #250
Closes #250

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