mirror of
https://github.com/paradigmxyz/solidity-lean.git
synced 2026-11-15 19:56:39 +00:00
`data.pop;` (and `data.push;`) names the builtin storage `bytes`/dynamic-array
`push`/`pop` MUTATION member as a discarded expression statement. solc 0.8.35 +
EVM accept it (with a "statement has no effect" warning): the member access
yields the mutation function's type, but nothing CALLS it, so the pop/push never
runs — storage is unchanged — and the function runs to the end returning its
default (measured EVM return `0x00…00`). Only a genuine CALL (`data.pop()`)
mutates.
solidity-lean fail-closed at typecheck (over_reject): `checkExpr`'s
`Expr.member base member` arm has no VALUE form for an uncalled `push`/`pop` —
they are call-only mutation members, resolved only in `checkArrayMutationCall?`
at a CALL site — so the bare reference fell to `unsupported "member pop"`.
Fix (mirrors the LIBRARY / ABI / UDVT STRAY-VALUE arcs, #69/#70/#71), two seams:
* TypeCheck.checkStmt: accept a bare `x.push;`/`x.pop;` expression statement as
a no-op, gated (statement position only) on a plain identifier base that is
genuinely a storage dynamic array / `bytes` — the SAME success condition as
the storage push/pop CALL path in `checkArrayMutationCall?`
(`dynamicStorageArrayElement?.isSome && dataLocation? == storage`). The same
member in a CONVERSION position, on a fixed-size array, or on a
memory/calldata receiver still routes through the unchanged `checkExpr` and
stays rejected.
* Lowering: `Expr.isStrayLibraryFunctionValue` now also matches a bare
`x.push`/`x.pop` member value, dropped by `Stmt.dropStrayLibraryFunctionValues`
in FunctionDecl.toCore? so it never reaches core lowering (which has no value
form for an uncalled mutation member). A bare member-value expression
statement has no side effects, so lowering it to a no-op is sound.
Regression witness SolidCore/Witness/ByteArrayPopStrayValue.lean pins the
submission's exact solc+EVM observable (`test()` returns `x == 0`, not a
fail-closed reject / Panic), a `push` control, and a fixed-array control that
must stay rejected. 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>
133 lines
5.5 KiB
133 lines
5.5 KiB