Conversation
Summary of fixes for bug #93: | Location | Issue | Fix | |---------------------------------|----------------------------------------|--------------------------------------------------------------| | Statement::If (line 711-762) | Used abstract inference + apply_effect | Changed to infer_statements_from(&branch, &stack_after_cond) | | Statement::Match (line 654-658) | Used abstract inference + apply_effect | Changed to infer_statements_from(&arm.body, &arm_stack) | Other locations checked: - Statement::Quotation (line 793) - Uses abstract inference but this is correct because quotations are deferred execution; they don't execute with the current stack. Tests added: 1. test_roll_inside_conditional_with_concrete_stack - Bug #93 reproduction case 2. test_roll_inside_match_arm_with_concrete_stack - Same pattern for match 3. test_roll_with_row_polymorphic_input - Ensures stdlib still works 4. test_pick_with_row_polymorphic_input - Ensures stdlib still works The core issue was that infer_statements creates a fresh row variable, so n roll/n pick would generate unconstrained phantom types. By using infer_statements_from with the actual concrete stack, operations can see what types are available.
Pull Request Review: Fix Issue #93SummaryThis PR fixes a critical type checker bug where ✅ Strengths1. Correct Root Cause AnalysisThe fix properly identifies that the issue was using 2. Comprehensive Test CoverageThe PR adds 4 well-designed tests:
These tests cover both the bug fix AND regression prevention for legitimate polymorphic use cases. 3. Excellent DocumentationThe added comments clearly explain:
4. Minimal, Focused ChangesThe fix touches only what's necessary:
5. Proper Substitution CompositionThe fix in let total_subst = cond_subst
.compose(&then_subst)
.compose(&else_subst)
.compose(&branch_subst);This was missing before and could have caused subtle bugs. 🔍 Observations & Minor Concerns1. Substitution Handling in Match ArmsLooking at lines 654-661, I notice that 2. Test Assertions Could Be StrongerThe new tests check that type checking succeeds ( let result = checker.check_program(&program).unwrap();
// Verify the inferred effect matches expectations3. Edge Case: Empty Else BranchLine 746-747 handles the case when 🔒 Security Considerations✅ No security concerns. This is a type checker fix that improves correctness without introducing vulnerabilities. ⚡ Performance Considerations✅ Neutral to slightly positive:
🏗️ Code QualityExcellent:
Minor Nitpick:Line 655-656 comment could be more concise: // Type check arm body from concrete stack (needed for n roll/pick)📋 RecommendationsMust Have:✅ All critical items are already addressed Nice to Have:
Questions for Author:
🎯 Final VerdictRecommendation: ✅ APPROVE with minor suggestions This is a high-quality fix that:
The bug was a genuine type system flaw, and this PR fixes it the right way. The added comments will help future maintainers understand this subtle aspect of the type checker. Suggested next steps:
Great work tracking down this tricky type system bug! The fix demonstrates a solid understanding of row polymorphism and stack effect inference. 🎉 |
fix #93
Summary of fixes for bug #93:
Other locations checked:
Tests added:
The core issue was that infer_statements creates a fresh row variable, so n roll/n pick would generate unconstrained phantom types. By using infer_statements_from with the actual concrete stack, operations can see what types are available.