solidity-lean/SolidCore/Witness/EmitStorageDynamicArray.lean
arena-lean-staging-agent[bot] 389dba342f
fix: emit-event args must materialize a bare storage bytes/string/array (#7) (#2)
An event argument is a value-use boundary: EventDecl.encodeFields? ABI-encodes
the argument CONTENTS from the field types and cannot read storage. A bare state
bytes/string/array/struct lowers to Expr.storage key, whose eval is the HEADER
word (the .length convention), so abiEncodeValues? for a dynamic field returned
none -> RevertData.typeMismatch = Panic(0). solc+EVM instead implicitly copy the
storage value to memory before emitting, so the event carries the full ABI
encoding.

Both Stmt.emitEvent core-lowering arms (bare ident callee and qualified member
callee) now rewrite their lowered args with materializeStorageValueUseCores,
mirroring the other value-use boundaries (abi.encode*/keccak256/abi.decode/
tuple-RHS). Bare-storage args load their full contents (Expr.storagePath key []);
every other core shape passes through untouched, so non-storage emits stay
byte-identical.

Witness: SolidCore/Witness/EmitStorageDynamicArray.lean.

Co-authored-by: Lean Semantics Review Agent <agent@solidcore.local>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-19 05:36:43 +00:00

146 lines
4.9 KiB