Allow payload-sensitive helper match dispatch#38
Merged
Conversation
Permit source helper whole-body matches and helper return-match expressions to repeat a top-level enum constructor when their nested typed enum payload predicates are provably disjoint. Resolve helper match candidates by checking concrete source payloads against typed guards before binding nested values, while preserving wildcard fallback behavior and fail-closed diagnostics for uncovered payload shapes. Keep same-message payload splitting rejected for step signatures and process match-msg dispatch so the Strata/Mantle runtime boundary remains explicit. This change does not alter Mantle artifact schema, lowering semantics, or runtime transition lookup. Document the helper-only semantics and diagnostics, and add focused positive and negative nested-pattern tests for duplicate predicates, guarded/unguarded overlap, unproven overlap, uncovered payloads, wildcard fallback, and still-rejected step dispatch forms.
There was a problem hiding this comment.
Pull request overview
This PR extends Strata’s source helper match dispatch to allow repeating the same top-level enum constructor when the nested typed-enum payload predicates are provably disjoint, enabling payload-sensitive helper dispatch at checker/expansion time (without changing lowering or the Mantle artifact/runtime behavior).
Changes:
- Add payload-sensitive match-arm validation that permits same-constructor repeats only when nested typed-enum guards are disjoint, and rejects overlaps/duplicates.
- Update helper expansion (match + return match) to select arms by testing the concrete nested payload against typed guards before binding nested values; improve “no matching pattern” diagnostics.
- Document the helper-only semantics and add tests covering accepted splits and rejected overlaps/uncovered shapes (while ensuring process step/message dispatch behavior is unchanged).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents helper-only constructor splitting based on provably-disjoint nested predicates. |
| docs/src/syntax-reference.md | Notes helper match/return-match support for splitting by disjoint nested enum predicates. |
| docs/src/language-reference.md | Adds a worked example and clarifies the allowed/rejected cases for helper-only splitting. |
| docs/src/diagnostics.md | Adds diagnostics entries for overlap rejection and expansion-time “no matching pattern” failures. |
| crates/strata/src/language/tests/nested_pattern_destructuring.rs | Adds coverage for accepted helper dispatch splitting and expected rejection/diagnostics for overlaps and uncovered payload shapes. |
| crates/strata/src/language/checker/source_functions/values/return_matches.rs | Uses payload-sensitive arm checking for helper return-match validation. |
| crates/strata/src/language/checker/source_functions/value_resolution/return_matches.rs | Updates expansion-time return-match arm selection to filter by payload guard prior to binding; improves diagnostics. |
| crates/strata/src/language/checker/source_functions/value_resolution/body_matches.rs | Updates expansion-time whole-body helper match arm selection similarly (guard check before binding) and improves diagnostics. |
| crates/strata/src/language/checker/source_functions/match_bodies.rs | Uses payload-sensitive arm checking for helper whole-body match validation. |
| crates/strata/src/language/checker.rs | Introduces payload-sensitive typed arm validation, disjointness checking for nested guards, and source-payload guard matching helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Boundary
Tests