Conversation
Changes made:
1. Runtime (crates/runtime/src/variant_ops.rs):
- Added patch_seq_make_variant_5 through patch_seq_make_variant_12
- Added re-exports for internal use
2. Runtime exports (crates/runtime/src/lib.rs):
- Added exports for new make_variant functions
3. Builtin signatures (crates/compiler/src/builtins.rs):
- Added signatures for variant.make-5 through variant.make-12 (using a loop since the macro only supports up to 5 inputs)
- Added signatures for wrap-5 through wrap-12
- Added docs for all new builtins
4. Codegen (crates/compiler/src/codegen/runtime.rs):
- Added LLVM declarations for new runtime functions
- Added builtin-to-runtime mappings
5. AST (crates/compiler/src/ast.rs):
- Changed MAX_VARIANT_FIELDS from 4 to 12
6. Documentation:
- Updated language-guide.md (comparison table, error example)
- Updated STDLIB_REFERENCE.md (variant constructors table)
- Updated ARCHITECTURE.md (comment about field count)
Pull Request Review: Bump variant field limit from 4 to 12SummaryThis PR systematically extends the maximum variant field count from 4 to 12 by adding new runtime functions, compiler builtins, and LLVM declarations. The implementation follows the established patterns and maintains consistency across the codebase. ✅ Strengths1. Comprehensive Coverage
2. Code Quality
3. Documentation
4. Type Safety
🔍 Observations & Suggestions1. Code Duplication (Minor)The new variant functions (5-12) follow an extremely repetitive pattern with only the field count changing. While this matches the existing style for functions 0-4, consider whether a macro could reduce duplication in the future. Note: This is purely an observation for future consideration. The current implementation is correct and consistent with the established codebase patterns. 2. Test Coverage (Important)I do not see integration tests that exercise variants with 5-12 fields. The existing test file tests/integration/src/test-variant-typed.seq only tests up to 4 fields. Recommendation: Add test cases for the new field counts to ensure they work correctly in practice. At minimum, test one mid-range variant (e.g., 8 fields) and the maximum (12 fields). 3. Performance Considerations (Minor)Each variant function allocates a new Vec with all fields. For variants with 12 fields, this involves 12 stack pops, creating a Vec with 12 elements, and Arc allocation for VariantData. This is consistent with the existing implementation and likely acceptable for the use case. However, if variant creation becomes a bottleneck, consider pre-allocating the Vec with capacity. 4. Error Handling (Good)The panic messages are clear and consistent, matching the existing pattern and will help users debug issues. 🔒 Security Considerations
🐛 Potential BugsNo bugs identified. The implementation correctly:
📊 Overall AssessmentRecommendation: ✅ APPROVE with suggestion to add tests This is a clean, well-executed PR that maintains code quality and consistency. The only substantive improvement would be adding integration tests for the new variant sizes to ensure they work correctly in practice. The implementation:
Great work maintaining consistency across the entire codebase! Generated by Claude Code - PR review for #294 |
Changes made:
- Added patch_seq_make_variant_5 through patch_seq_make_variant_12
- Added re-exports for internal use
- Added exports for new make_variant functions
- Added signatures for variant.make-5 through variant.make-12 (using a loop since the macro only supports up to 5 inputs)
- Added signatures for wrap-5 through wrap-12
- Added docs for all new builtins
- Added LLVM declarations for new runtime functions
- Added builtin-to-runtime mappings
- Changed MAX_VARIANT_FIELDS from 4 to 12
- Updated language-guide.md (comparison table, error example)
- Updated STDLIB_REFERENCE.md (variant constructors table)
- Updated ARCHITECTURE.md (comment about field count)