Support macro binds for array-return helpers#1869
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 497b62b. Configure here.
| $(strTerm paramName) | ||
| $(natTerm wordOffset)) | ||
| else if let some (name, _) := localMemoryArray? locals name then | ||
| `(Compiler.CompilationModel.Expr.memoryArrayLength $(strTerm name)) |
There was a problem hiding this comment.
Inconsistent check ordering between type inference and translation
Low Severity
In the arrayLength handling, inferPureExprType checks localMemoryArray? before paramDynamicMemberProjection?, but translatePureExprWithTypes checks paramDynamicMemberProjection? before localMemoryArray?. If a name ever matched both predicates, type inference and code generation would disagree on which branch to take, producing mismatched semantics. The arrayElement case has consistent ordering in both functions, making this arrayLength discrepancy likely unintentional.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 497b62b. Configure here.


Summary
let xs ← helperReturningArray ...toStmt.internalCallAssign [xs_data_offset, xs_length] ...arrayLength xs,arrayElement xs i, and forwardingxsinto Array helper params through memory-array offset/length localsVerification
lake build Compiler.CompilationModelFeatureTestgit diff --checkNote
Medium Risk
Touches macro translation and typing/lowering for internal helper calls returning arrays, which can affect generated IR/Yul for dynamic array handling and call argument passing. Scope is constrained to Array returns and covered by new regression tests.
Overview
Macros can now
let xs ← helperReturningArray ...and treatxsas a memory-backed array local represented byxs_data_offset/xs_lengthlocals, lowered viaStmt.internalCallAssign.arrayLength xs,arrayElement xs i, and passingxsinto other helperArrayparameters are updated to lower through newExpr.memoryArrayLength/Expr.memoryArrayElementpaths whenxscomes from an internal helper array return (restricted toArray<wordLike>).Adds
CompilationModelFeatureTestregressions that assert the new lowering for length reads, element reads, and forwarding a returned array through another helper call.Reviewed by Cursor Bugbot for commit 497b62b. Bugbot is set up for automated code reviews on this repo. Configure here.