mirror of
https://github.com/paradigmxyz/solidity-lean.git
synced 2026-11-15 19:56:39 +00:00
#158 (4ab278c) replaced the lowering-time using-for bind predicate `Ty.matchesShape` with the directional `Ty.canImplicitlyConvert` (in `FunctionDecl.firstParamMatchesWithInternalFunctions?` and `Parameter.matchesArgWithInternalFunctions?`) so a `uint8` receiver could widen-bind `f(uint256 self)`. But `canImplicitlyConvert`'s struct/user arms are exact `==` only: a STORAGE-STRUCT receiver whose reflected `abiTy` path is namespace-qualified (e.g. `OpenZeppelinEnumerableMap.UintToAddressMap`, or `M.Box`) never `==`s the library parameter's resolved struct type (segments differ), so the using-for method call silently stopped binding at lowering. That regressed the whole OpenZeppelin EnumerableMap replay lane — every `_owners.set/.contains/.get` lowered to a default-zero read, flipping two runtime assertions from `Except.ok true` to `Except.ok false` (acceptance was unaffected; the typechecker uses a separate predicate, which is why `importedSourceUnitAccepted` stayed true). Bisect (worktree, per-commit build+`--only openzeppelin-enumerable-map`):3e00bf9(#159) GREEN →4ab278c(#158) FALSE →1d73b6d(#157) FALSE →272e763(#156) FALSE. Culprit:4ab278c(#158). #156 was NOT the cause (removing it did not fix the lane). Fix (SolidCore/Solidity/Interface.lean): OR the pre-#158 nominal predicate back in at both sites — `canImplicitlyConvert argTy paramTy || matchesShape argTy paramTy`. The widening case still succeeds via `canImplicitlyConvert`; the nominal struct/user (and array/mapping/tuple) case binds again via `matchesShape` → `Path.matchesNominal`. Every `canImplicitlyConvert` reject (narrowing, uint→bytes32, signedness) is ALSO a `matchesShape` reject, so #158's over-accept guards are preserved (verified: using-for-widen lane still solc_rejects=ok, its 3 reject `#guard`s and 3 widen runtime `#guard`s all pass). Regression guard: SolidCore/Witness/UsingForStructReceiverBind.lean — EXECUTES a using-for call on a storage-struct receiver whose state-var path (`M.Box`) differs from the library first-parameter path (`Box`) — the exact shape `canImplicitlyConvert`-alone cannot bind — and `#guard`s the round-tripped value is 42. Imported from SolidCore.lean. (Negative control by inspection: `canImplicitlyConvert (Ty.user ["M","Box"]) (Ty.user ["Box"])` = false, no nominal arm; `matchesShape` = `Path.matchesNominal ["M","Box"] ["Box"]` = true.) Gate: full `lake build` green (1120 jobs, incl. FuelMonotonicity + all witnesses). Harness --only openzeppelin-enumerable-map: status=0 (lean=ok, restored ['true','Except.ok true','Except.ok true']). --only using-for-widen: status=0 (solc_rejects=ok forge/lean ok). #156 lib-storage-return-use witness still builds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> (cherry picked from commit 98495dc140e92a949c49d79942ba2ee2773d7a0b)
180 lines
7.2 KiB
180 lines
7.2 KiB