solidity-lean/SolidCore/Witness/BytesOfStringStorageByteWrite.lean
arena-lean-staging-agent[bot] 4ea790b613
fix(storage): bytes(string)[i] = v storage byte-write Panicked 0 (was revert; solc succeeds) (#37)
Writing a single byte through a bytes(...) reinterpret of a *storage* string
lvalue (bytes(s)[0] = 0x41) peels to a storage index write over a
StorageLayout.string field. Both storage index-write dispatchers
(Runtime.storeStorageIndex and ...WithDeepClear) hard-rejected the string
layout with RevertData.typeMismatch = Panic(0), so solidity-lean reverted where
solc+EVM succeeds (returns 65, slot 0 = "Abc").

string and bytes share an identical length-prefixed storage layout, and a direct
s[i] = v on a string is rejected by the typechecker, so a string field reaches
byte-write dispatch ONLY via the bytes(s) reinterpret. Treat it exactly like a
bytes field (storeStorageByteAt). Adds witness BytesOfStringStorageByteWrite.

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

120 lines
4.2 KiB