Support dynamic array element aliases#1866
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cc0c5c7. Configure here.
| some (paramName, index, elemTy) | ||
| else | ||
| none | ||
| | _ => none |
There was a problem hiding this comment.
New function duplicates existing arrayElementDynamicTupleArg? exactly
Low Severity
arrayElementAliasSource? is character-for-character identical to the existing arrayElementDynamicTupleArg? — same signature, same logic, same return type. One of the two can be removed and the other reused at all three call sites.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit cc0c5c7. Configure here.
| unless externalCallDynamicArgSupported (.array elemTy) do | ||
| throwErrorAt x s!"externalCall '{extName}' dynamic-member alias argument currently supports only Array<wordLike> members, got {renderValueType fieldTy}" | ||
| | _ => | ||
| throwErrorAt x s!"externalCall '{extName}' dynamic-member alias argument requires an Array-typed member, got {renderValueType fieldTy}" |
There was a problem hiding this comment.
Type checker accepts alias projections that translator cannot lower
Medium Severity
inferPureExprType now accepts localArrayElementDynamicMemberProjection? arguments for inline externalCall and tryExternalCall expressions, but the corresponding externalCall translation path in translatePureExprWithTypes has no matching handling — it falls through to the generic recursive call, which cannot translate a dynamic member projection as a standalone expression and will throw an "unsupported expression" error at translation time.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit cc0c5c7. Configure here.


Summary
arrayElement <param> <index>bindings in the macro local contextabiHeadWord, dynamic-memberarrayLength/arrayElement, and helper/external array arguments back to the original calldata array elementTesting
lake build Contracts.Smoke.FixedArrayStructSmokelake build Contracts.Smoke Contracts.MacroTranslateInvariantTest Contracts.MacroTranslateRoundTripFuzz Compiler.CompilationModelFeatureTestlake build PrintAxiomspython3 scripts/generate_print_axioms.py --checkpython3 scripts/check_axioms.pygit diff --checkNote
Medium Risk
Touches core macro translation/type-inference for expression lowering, so regressions could affect many contracts that project into dynamic calldata arrays or pass dynamic members to helpers/external calls.
Overview
Adds first-class tracking for immutable locals that alias
arrayElement <param> <index>(newTypedLocal+LocalSource) so the macro can recognize when a local name is really a dynamic calldata array element.Extends type inference and lowering to resolve struct field reads,
abiHeadWord, dynamic-memberarrayLength/arrayElement, tuple-destructuring guards, and helper/external-call dynamic arguments through these aliases, emitting the sameExpr.arrayElementDynamicWord/Expr.arrayElementDynamicMember*forms as directarrayElementusage.Updates smoke/invariant tests (
FixedArrayStructSmoke, selector/signature snapshots) to cover alias-based head-word reads and dynamic member length reads.Reviewed by Cursor Bugbot for commit cc0c5c7. Bugbot is set up for automated code reviews on this repo. Configure here.