Skip to content

Support dynamic struct element helper args#1862

Merged
Th0rgal merged 4 commits into
mainfrom
codex/dynamic-struct-helper-args
May 14, 2026
Merged

Support dynamic struct element helper args#1862
Th0rgal merged 4 commits into
mainfrom
codex/dynamic-struct-helper-args

Conversation

@Th0rgal
Copy link
Copy Markdown
Member

@Th0rgal Th0rgal commented May 14, 2026

Summary

  • add IR/Yul helpers for forwarding dynamic struct-array elements into internal helpers
  • support dynamic tuple parameter member length/data/element projection in the macro
  • add smoke, invariant, round-trip, and generated property-test coverage

Tests

  • lake build
  • lake build Contracts.Smoke
  • lake build Compiler.Proofs.IRGeneration.ExprCore
  • python3 scripts/check_macro_health.py

Note

Medium Risk
Touches ABI encoding/offset calculations and macro lowering for dynamic tuple/struct parameters, which can cause subtle miscompilations if offsets/length checks are wrong; changes are localized but span compiler, validators, and proofs.

Overview
Adds new IR/Yul support for passing dynamically encoded struct/tuple values into internal helpers by introducing Expr.arrayElementDynamicDataOffset plus dynamic-member projections (Expr.paramDynamicMemberLength, Expr.paramDynamicMemberDataOffset, Expr.paramDynamicMemberElement) and compiling them to new checked Yul helpers (calldata + memory variants).

Extends validation/usage analysis/purity checks and internal helper parameter lowering to recognize these new expression forms, and updates the macro translator to lower dynamic struct-member uses in arrayLength/arrayElement, external/linked calls, and internal helper calls (including allowing struct/tuple helper params).

Adds a new smoke contract (DynamicStructElementHelperArgSmoke) and updates invariant/round-trip fuzz suites and generated Solidity property-test scaffolding; the property-test generator now falls back to an abi.decode(abi.encode(...)) placeholder for unsupported array element example values instead of failing.

Reviewed by Cursor Bugbot for commit 92514c6. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 695cc13. Configure here.

| Expr.paramDynamicMemberLength _ _
| Expr.paramDynamicMemberDataOffset _ _ => true
| Expr.paramDynamicMemberElement _ _ innerIndex =>
exprUsesParamDynamicHeadWord innerIndex
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing unconditional true for paramDynamicMemberElement usage detection

High Severity

exprUsesParamDynamicHeadWord returns exprUsesParamDynamicHeadWord innerIndex for Expr.paramDynamicMemberElement, but it needs to return true unconditionally (like paramDynamicMemberLength and paramDynamicMemberDataOffset do). The checkedParamDynamicMemberElementHelper is gated by paramDynamicHeadWordHelpersRequired, so if a function only uses paramDynamicMemberElement with a simple literal index, the helper won't be emitted and the generated Yul will reference an undefined function.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 695cc13. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

\n### CI Failure Hints\n\nFailed jobs: `compiler-regressions`\n\nCopy-paste local triage:\n```bash\nmake check\nlake build\nFOUNDRY_PROFILE=difftest forge test -vv\n```

@Th0rgal Th0rgal merged commit b49c511 into main May 14, 2026
6 checks passed
@Th0rgal Th0rgal deleted the codex/dynamic-struct-helper-args branch May 14, 2026 10:46
Th0rgal added a commit that referenced this pull request May 14, 2026
Updates the public/private theorem index to include the 5 new IR Expr
constructors (arrayElementDynamicDataOffset, arrayElementDynamicMemberDataOffset,
paramDynamicMember{Length,DataOffset,Element}) shipped in upstream PRs
#1858-#1862, plus the dispatchBody / DynamicData helpers they reference.

Followup to the merge commit `60d38ba8`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant