Conversation
- Implement rules for nested compound types, including depth restrictions and uzumaki assignments. - Introduce diagnostics for exceeding nested compound depth and invalid uzumaki usage on nested structs and arrays. - Update documentation and tests to cover new rules and ensure correct behavior.
…ror messages in negative tests
- Updated memory layout computation to handle nested structs and arrays. - Introduced a visited set to prevent cycles during type size calculations. - Added tests to validate the handling of nested structs, including creation, reading, and writing fields. - Enhanced type checker to accept nested struct literals, ensuring compatibility with code generation. - Regenerated WASM and WAT files for nested struct examples.
- Removed unnecessary pointer adjustments in multiple `.wat` files for consistency and clarity. - Updated binary `.wasm` files for `method_instance`, `method_multi_struct`, `method_return_struct`, `method_self_mutate`, `method_three_fields`, `nested_struct`, `struct_access`, `struct_assign`, `struct_copy`, `struct_literal`, `struct_params`, and `struct_return`. - Added new struct definition and methods for `struct_with_array`, including tests for array access and manipulation.
…ion and add corresponding tests
…eneration and add corresponding tests
- Implement rule A029: Prevent compound literals from being assigned directly to struct fields. - Implement rule A030: Reject uzumaki assignments to arrays with more than 2 dimensions. - Update error handling to include new diagnostics for these rules. - Add integration tests for both rules to ensure correct behavior. - Modify code generation to support new array and struct handling.
- Added a new rule (A031) to disallow complex return expressions in functions returning compound types (structs or arrays). - Updated existing rule A029 to reflect changes in compound assignment restrictions, now including array index expressions. - Refactored memory copy instructions in the WASM code generation to use a helper function for better readability and maintainability. - Enhanced tests for rules A029 and A031, ensuring proper validation of compound literals in assignments and return expressions. - Updated dependencies in Cargo.toml files to include new features for testing utilities.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Implements codegen support for nested compound types (struct-in-struct, array-in-struct, struct-in-array) by making size/layout computation recursive and updating member/array access lowering to work with pointer semantics for compound fields, closing #161. Adds new analysis rules (A026–A031) to constrain unsupported nesting/uzumaki/compound-return patterns, and updates/extends golden WASM fixtures and tests accordingly.
Changes:
- Add recursive type size + struct field layout computation (with cached sub-layouts) and update WASM lowering to handle compound field/element access via pointers and
memory.copy. - Introduce analysis rules A026–A031 for nested compound depth, uzumaki restrictions, compound literal assignment restrictions, deep-array uzumaki, and compound-return expression constraints.
- Update type-checker struct-literal field typing, add
test-utilsfeature to register structs inTypedContext, and refresh test fixtures + dependencies.
Reviewed changes
Copilot reviewed 47 out of 66 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
core/wasm-codegen/src/memory.rs |
Recursive byte-size/alignment and struct field layout computation; caches nested layouts for chained access. |
core/wasm-codegen/src/compiler.rs |
Updates lowering for compound member/array access, copies, sret returns, and struct/array literal handling. |
core/analysis/src/walker.rs |
Adds compound-type helpers used by new rules. |
core/analysis/src/rules/* |
Adds rules A026–A031 and registers them. |
core/analysis/src/errors.rs |
Adds diagnostics for A026–A031. |
core/analysis/src/lib.rs |
Updates docs and rule/diagnostic parity test list. |
core/type-checker/src/type_checker.rs |
Resolves custom types in struct literal field checking. |
core/type-checker/src/typed_context.rs |
Adds register_test_struct behind test-utils feature. |
core/type-checker/Cargo.toml |
Adds test-utils feature flag. |
tests/src/analysis/* |
New integration tests for A026–A031. |
tests/src/type_checker/struct_tests.rs |
Updates expectations and adds tests for nested structs / arrays-of-struct literals. |
tests/src/type_checker/type_checker.rs |
Refactors assertions / pattern matching in tests. |
tests/src/codegen/wasm/negative.rs |
Updates negative/positive expectations for compound types and reassignment behavior. |
tests/Cargo.toml |
Bumps wasmtime and enables inference-type-checker test-utils feature. |
core/wasm-codegen/Cargo.toml |
Enables inference-type-checker test-utils for codegen unit tests. |
tests/test_data/codegen/wasm/base/** |
Adds/updates golden .wat/.wasm/.inf fixtures for new compound-type behaviors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 47 out of 66 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix doc comment range A022-A030 -> A022-A031 and A027 error message - Replace bare unwrap with descriptive expect, use checked arithmetic for offset additions - Resolve custom types in MemberAccess handler for type consistency - Convert cycle detection assert!/panic! to Result<_, CodegenError> in memory.rs - Fix A028+A030 double diagnostic by adding depth guard to A028 - Add MAX_UZUMAKI_UNROLL_ELEMENTS guard against instruction explosion - Add A031 end-to-end rejection test and Deep struct param/return tests - Split A031 tests into dedicated rules_a031.rs file - Optimize frame allocation to share slots across if/else branches Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 49 out of 68 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 50 out of 70 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…s and multidimensional arrays
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 50 out of 70 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Implemented recursive handling for multidimensional scalar arrays in uzumaki expressions, allowing arrays of any depth. - Updated the compiler to calculate total leaf counts and handle leaf scalar types correctly. - Modified the code generation logic to emit appropriate uzumaki and store instructions for nested arrays. - Enhanced error handling and validation for array uzumaki operations. - Added tests to ensure correct behavior for 3D and 4D array uzumaki, including inline validation. - Removed the restriction on multidimensional arrays for uzumaki, previously governed by analysis rule A030. - Updated related tests to reflect the new behavior and ensure compliance with the updated rules.
Closes #161