Thread length into static array ABI hashing#1864
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 b511cec. Configure here.
| ]), | ||
| YulStmt.let_ dataBytesName (YulExpr.call "mul" [ | ||
| YulExpr.ident s!"{arrayParam}_length", | ||
| arrayLengthExpr, |
There was a problem hiding this comment.
Array length expression inlined twice without binding
Low Severity
arrayLengthExpr is used twice in the generated Yul block (in mstore at the first use and mul at the second) without being bound to a Yul let variable first. The old code was inherently safe because it hardcoded YulExpr.ident s!"{arrayParam}_length", always a simple variable reference. The new code accepts an arbitrary compiled YulExpr, which gets duplicated in the AST. Other modules in the same file (e.g., abiEncodePackedWordsModule) use packedWordBindings to bind each argument expression to a local before use. Introducing a let binding for the length expression would match the established convention and prevent double evaluation if a non-trivial expression is ever supplied.
Reviewed by Cursor Bugbot for commit b511cec. Configure here.
| \n### CI Failure Hints\n\nFailed jobs: `checks`\n\nCopy-paste local triage:\n```bash\nmake check\nlake build\nFOUNDRY_PROFILE=difftest forge test -vv\n``` |


Summary
This avoids the zero-argument ecmCall source-surface edge case while preserving the ABI layout helper added in #1863.
Verification
Note
Medium Risk
Medium risk because it changes the
abiEncodeStaticArrayECM call surface/arity and threads length through codegen, which could break callers or alter hashing if the wrong length expression is provided.Overview
abiEncodeStaticArrayis refactored so the ECM takes the dynamic array length as an explicit expression argument (numArgs0→1) instead of implicitly reading{arrayParam}_length, and the generated Yul now uses that provided length when writing the ABI head/length and computing payload byte size.Feature tests are updated to pass
Expr.arrayLengthintoCompiler.Modules.Hashing.abiEncodeStaticArray, and the bad-arity regression now expects the new 1-arg ECM shape (updated compile-error message/inputs).Reviewed by Cursor Bugbot for commit b511cec. Bugbot is set up for automated code reviews on this repo. Configure here.