mirror of
https://github.com/paradigmxyz/solidity-lean.git
synced 2026-11-15 19:56:39 +00:00
`a3[0][1] = [5,6]` for a nested `uint8[]` storage element (and the flat
`uint8[] s; s = [5,6]`) is accepted and run by solc 0.8.35: the literal is
typed bottom-up as `uint8[2] memory` and copied (fixed->dynamic storage copy)
into the dynamic storage array.
solidity-lean failed closed at typecheck (over_reject): `[5,6]` carried the
over-wide `uint256[2]` `checked.ty`, and the `=` storage-array-copy branch used
that instead of solc's bottom-up mobile type, so `storageArrayCopyAssignable?`
saw a uint256->uint8 narrowing and rejected. Once accepted, the interpreter
Panic(0)'d: `State.storeStorageLayoutAt` at a `dynamicArray` layout demanded a
`Value.dynamicArray`, but a memory array literal is a `Value.fixedArray`.
Fix (two minimal seams):
* TypeCheck: the storage-array-copy branch substitutes the inline literal's
bottom-up type (`inlineArrayBottomUpTy?`) for its over-wide `checked.ty`; a
typed/variable element leaves it `none`, keeping `checked.ty` (and the
struct-element legacy carve-out).
* Interpreter: `storeStorageLayoutAt` accepts a `Value.fixedArray` at a
`dynamicArray` layout (resize to the source length, copy) — the fixed->dynamic
storage copy.
Regression witness `NestedArrayLiteralStorageCopy` pins the submission's exact
solc+EVM storage (slot 0 = 1, keccak(0) = 0, keccak(0)+1 = 2, data slot = 0x0605)
plus flat and fixed controls. Full `lake build` (all proofs + witnesses) green.
Co-authored-by: Lean Semantics Review Agent <agent@solidcore.local>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
163 lines
6.3 KiB
163 lines
6.3 KiB