Conversation
…nd corresponding tests
…ions and corresponding tests
…gnments and expressions - Added tests to ensure that assigning from functions returning structs is rejected. - Updated existing tests to check for error messages related to compound-returning function calls. - Introduced new tests for standalone expressions and method calls that return structs. - Added tests for methods and associated functions returning primitives to confirm they are allowed in standalone contexts. - Created new test cases for struct methods that mutate self, ensuring value semantics are maintained. - Added code generation tests for methods across multiple structs and self-mutating methods in WebAssembly.
- Updated method names in WASM and WAT files to follow a consistent naming convention (e.g., changed `Point__get_x` to `Point.get_x`). - Introduced new structs and methods for handling arrays and i64 fields: - Added `Pair` struct with methods to convert to an array and retrieve individual fields. - Added `BigPair` struct with methods to get individual i64 fields and calculate their sum. - Added `Vec3` struct with methods to retrieve individual fields and calculate their sum. - Created corresponding test functions for the new structs and methods to ensure functionality. - Updated binary files for the changes made to the WASM modules.
There was a problem hiding this comment.
Pull request overview
Adds WebAssembly codegen support for methods, including self parameter handling, instance method call lowering (instance.method()), and associated function lowering (Type::new()), along with updated type-checker restrictions/tests for compound-return call positions.
Changes:
- Extend WASM codegen traversal to index and compile both top-level functions and struct methods using mangled names (
TypeName.method). - Implement lowering for instance method calls and associated functions, including
mut selfcopy-on-entry semantics. - Add/update codegen fixtures and Rust tests for method codegen + tighten type-checker diagnostics around compound-return calls in unsupported positions.
Reviewed changes
Copilot reviewed 33 out of 42 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| core/wasm-codegen/src/lib.rs | Two-stage traversal: register indices for functions+methods, then compile bodies with method context. |
| core/wasm-codegen/src/compiler.rs | Core implementation for method name mangling, callee resolution, instance/associated call lowering, and self handling. |
| core/wasm-codegen/src/errors.rs | Adjust internal error docs after method/sret lowering changes. |
| core/type-checker/src/type_checker.rs | Enforce compound-return call placement rules across assignment/expr/arg/member-access/method-chain cases. |
| core/type-checker/src/errors.rs | Rename/expand error variants for compound-return call restrictions + add method-chain/assignment-specific errors. |
| core/type-checker/src/typed_context.rs | Add TypedContext::lookup_method() + MethodMetadata for downstream consumers. |
| core/type-checker/src/lib.rs | Re-export MethodMetadata. |
| core/type-checker/docs/errors.md | Rename error doc section to CompoundReturnCallInExpressionPosition. |
| core/type-checker/README.md | Update documentation to reflect new compound-return error naming/behavior. |
| core/analysis/README.md | Update references to renamed compound-return restriction error. |
| tests/src/type_checker/struct_tests.rs | Add type-checker tests for method-call chaining and compound-return restrictions with structs. |
| tests/src/type_checker/array_tests.rs | Update assignment-rejection test to assert the new compound-return assignment error message. |
| tests/src/codegen/wasm/validation.rs | Add validation tests for mangled method names, self lowering, and frame-copy expectations + helper extraction. |
| tests/src/codegen/wasm/base.rs | Add full fixture+equivalence+execution tests for method/associated calls, mutable self, sret returns, arrays, i64 fields, etc. |
| tests/test_data/codegen/wasm/base/method_instance/method_instance.inf | New method instance-call fixture source. |
| tests/test_data/codegen/wasm/base/method_instance/method_instance.wat | Expected WAT for method_instance. |
| tests/test_data/codegen/wasm/base/method_instance/method_instance.wasm | Expected WASM for method_instance. |
| tests/test_data/codegen/wasm/base/method_assoc/method_assoc.inf | New associated-function fixture source. |
| tests/test_data/codegen/wasm/base/method_assoc/method_assoc.wat | Expected WAT for method_assoc. |
| tests/test_data/codegen/wasm/base/method_assoc/method_assoc.wasm | Expected WASM for method_assoc. |
| tests/test_data/codegen/wasm/base/method_return_struct/method_return_struct.inf | New struct-returning method fixture source. |
| tests/test_data/codegen/wasm/base/method_return_struct/method_return_struct.wat | Expected WAT for method_return_struct. |
| tests/test_data/codegen/wasm/base/method_return_struct/method_return_struct.wasm | Expected WASM for method_return_struct. |
| tests/test_data/codegen/wasm/base/method_self_mutate/method_self_mutate.inf | New mut self semantics fixture source. |
| tests/test_data/codegen/wasm/base/method_self_mutate/method_self_mutate.wat | Expected WAT for method_self_mutate. |
| tests/test_data/codegen/wasm/base/method_self_mutate/method_self_mutate.wasm | Expected WASM for method_self_mutate. |
| tests/test_data/codegen/wasm/base/method_multi_struct/method_multi_struct.inf | New multi-struct (same method names) fixture source. |
| tests/test_data/codegen/wasm/base/method_multi_struct/method_multi_struct.wat | Expected WAT for method_multi_struct. |
| tests/test_data/codegen/wasm/base/method_multi_struct/method_multi_struct.wasm | Expected WASM for method_multi_struct. |
| tests/test_data/codegen/wasm/base/method_cross_call/method_cross_call.inf | New cross-calls (method↔method / method↔fn) fixture source. |
| tests/test_data/codegen/wasm/base/method_cross_call/method_cross_call.wat | Expected WAT for method_cross_call. |
| tests/test_data/codegen/wasm/base/method_cross_call/method_cross_call.wasm | Expected WASM for method_cross_call. |
| tests/test_data/codegen/wasm/base/method_array_return/method_array_return.inf | New method returning array fixture source. |
| tests/test_data/codegen/wasm/base/method_array_return/method_array_return.wat | Expected WAT for method_array_return. |
| tests/test_data/codegen/wasm/base/method_array_return/method_array_return.wasm | Expected WASM for method_array_return. |
| tests/test_data/codegen/wasm/base/method_i64_fields/method_i64_fields.inf | New i64 field access via methods fixture source. |
| tests/test_data/codegen/wasm/base/method_i64_fields/method_i64_fields.wat | Expected WAT for method_i64_fields. |
| tests/test_data/codegen/wasm/base/method_i64_fields/method_i64_fields.wasm | Expected WASM for method_i64_fields. |
| tests/test_data/codegen/wasm/base/method_three_fields/method_three_fields.inf | New 3-field struct method access fixture source. |
| tests/test_data/codegen/wasm/base/method_three_fields/method_three_fields.wat | Expected WAT for method_three_fields. |
| tests/test_data/codegen/wasm/base/method_three_fields/method_three_fields.wasm | Expected WASM for method_three_fields. |
| Cargo.toml | Bump tree-sitter-inference dependency version. |
💡 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 33 out of 42 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…tions and add corresponding test
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 36 out of 45 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…alls - Updated README.md to reflect the increase in error variants from 47 to 50. - Added new tests for distinguishing instance methods from associated functions in the type checker. - Implemented error handling for compound-returning method calls in expression positions. - Enhanced WASM code generation to support associated function calls and instance methods. - Introduced a new documentation file detailing type-checker-guarded panics to improve understanding of panic sites in the codebase. - Improved error messages and documentation throughout the type checker and codegen modules.
Closes #162