checking: handle rigid variables in open-row instance matching#124
checking: handle rigid variables in open-row instance matching#124bneiswander wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
SummaryThis PR fixes instance matching for open-row types containing rigid variables. Previously, instance patterns with rigid row variables were treated as non-matching candidates, leading to false-positive "no instance found" errors and incorrect fallback to else-instance branches even when an open rigid row could satisfy the instance requirement. ChangesConstraint Compiler Updates:
Test Coverage:
Validation
Merge Confidence4/5 The PR addresses a genuine constraint-solving bug with targeted fixes and appropriate test coverage. The approach of deferring instance matching when encountering rigid variables is sound and prevents premature elimination of valid candidates. However, constraint compiler changes carry inherent risk for broader type system impact, and full validation would benefit from extended integration test coverage and verification of related constraint patterns. WalkthroughThe pull request adds rigid variable detection to the constraint solver's row-type matchers. When ChangesRigid row variable deferral and else-instance matching
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Fix false NoInstanceFound errors when instances have open row patterns
(e.g., { | r }) that should match any row type including closed rows.
Three fixes:
1. match_row_type: treat rigid variables in instance patterns as matching any row
2. Row.Cons: defer to instance matching when arguments are rigid variables
3. RowToList: defer to instance matching when arguments or tails are rigid variables
Also commits pending fixture snapshots and adds test for open row instance matching.
Fix two snapshot mismatches on pr/checking-open-row-instance-matching: - 1772440440: swap ambiguous Lacks error order to match actual output - 1778704620: normalize source path to stable repo path
b0dfee5 to
8198efb
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #124 +/- ##
==========================================
- Coverage 83.09% 83.01% -0.08%
==========================================
Files 130 130
Lines 23812 23822 +10
Branches 23812 23822 +10
==========================================
- Hits 19786 19777 -9
- Misses 2238 2252 +14
- Partials 1788 1793 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
checking: handle rigid variables in open-row instance matching
Base branch:
mainReview Order
This PR is independent and can be reviewed against
mainat any time. It touches nearby row/matching internals, so reviewing it before the larger instance-chain PR may make later review easier, but it is not required.Summary
Motivation
The analyzer produced false-positive instance errors for open-row programs accepted by PureScript. The issue showed up when matching instance heads involving row primitives such as
Union,Cons, orLacksagainst rows whose tails were rigid rather than ordinary inference variables.Row matching needs to distinguish genuine apartness from a match that remains possible because a rigid open row may still satisfy the instance. Without that distinction, instance-chain selection can incorrectly fall through to an else branch or report ambiguity.
Motivating Example
The checker should not treat an open rigid row as immediately apart from an instance that can still match through the row tail:
Before this change, similar open-row instance matches could be considered apart too aggressively.
Implementation Notes
Tests
Added fixture:
1778704620_else_instance_open_row_matchUpdated existing snapshot:
1772440440_prim_row_openValidation run locally: