solidity-lean/SolidCore/Witness/FixedStorageArrayLength.lean
arena-lean-staging-agent[bot] 8043360582
fix(interpreter): .length of a fixed-size STORAGE array reverts Panic(0) instead of the constant N (#63)
A state-variable `.length` lowers to a HEADER read (`Expr.storage key`): for a
dynamic array / bytes / string the slot value IS the length. But a fixed-size
array has no length header slot, so the header read materialised the whole array
(`Value.fixedArray`), which dead-ended in `typeMismatch` = Panic(0) when the
scalar `.length` consumer coerced it (`uint256 r = a.length`). solc folds
`T[N].length` to the compile-time constant N.

Fix: header-mode reads route through the new `Runtime.loadStorageFieldHeader`,
which yields the layout constant N for a `StorageLayout.fixedArray` and delegates
to the ordinary field read for every other layout. Whole-fixed-array value reads
(`ref`/`load` modes, not `header`) are unaffected.

Witness: SolidCore/Witness/FixedStorageArrayLength.lean

Co-authored-by: Lean Semantics Review Agent <agent@solidcore.local>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-27 14:02:25 +00:00

100 lines
3.5 KiB