Conversation
⏺ All 20 tests pass including our new test. ⏺ Summary of the fix for Issue #65: 1. Root cause: The unify_types function in unification.rs didn't have a case for Type::Union. When unifying two union types (even identical ones like Union("Sexpr") with Union("Sexpr")), they fell through to the default _ catch-all case which always returns an error. 2. The bug was NOT related to includes - we reproduced it with a single-file test case. As you suspected, includes just flatten everything into a single code stream. 3. The fix: Added a simple pattern match case for union types: (Type::Union(name1), Type::Union(name2)) => { if name1 == name2 { Ok(Subst::empty()) } else { Err(format!("Type mismatch: cannot unify Union({}) with Union({})", name1, name2)) } } 4. Test added: tests/integration/src/test-union-same-type-fields.seq which creates a variant with two fields of the same union type.
PR Review: Fix for Union Type Unification (Issue #65)SummaryThis PR fixes a critical bug where union types couldn't be unified with themselves, causing compilation failures when variants had multiple fields of the same union type. The fix is clean, correct, and well-tested. Code Quality ✅Strengths:
The implementation at crates/compiler/src/unification.rs:142-152 is exactly right for nominal typing semantics where union types are identified by name. Test Coverage ✅Integration test is excellent:
Suggestion for improvement (minor): Potential Issues 🔍No bugs identified, but here are architectural considerations:
Performance Considerations ✅
Security Concerns ✅No security issues identified. The implementation uses safe Rust patterns and properly handles all cases. Documentation 📝The code is well-commented and the PR description provides excellent context about root cause analysis, why includes weren't the issue, the fix approach, and test validation. Architecture Consistency ✅The fix integrates perfectly with the existing Hindley-Milner unification algorithm and follows the same patterns as other concrete types. Recommendation: APPROVE ✓This is a high-quality fix that:
Optional enhancement: Add unit tests for Union type unification to strengthen the test suite, but this is not a blocker for merging. Great work isolating this bug and providing a clean, minimal fix! 🎉 |
⏺ All 20 tests pass including our new test.
⏺ Summary of the fix for Issue #65: