mirror of
https://github.com/paradigmxyz/solidity-lean.git
synced 2026-11-15 19:56:39 +00:00
`using L for uint8` attaching a library function whose FIRST parameter is WIDER than the target type was over-rejected. solc separates directive APPLICABILITY (usingForDirectivesForType: receiver type must EXACTLY equal the directive target, uint8==uint8 -- left unchanged) from function USABILITY (Type::attachedFunctions: the receiver need only be IMPLICITLY CONVERTIBLE to the function's first-parameter type). The model bound the first parameter (and the re-checked receiver + additional args) with exact-width Ty.matchesShape. Fix (SolidCore/Solidity/Interface.lean): use DIRECTIONAL Ty.canImplicitlyConvert in FunctionDecl.firstParamMatchesWithInternalFunctions? (receiver -> first param) and Parameter.matchesArgWithInternalFunctions? (re-checked receiver + additional args). Because convertibility is directional, the WIDER-receiver (uint256 recv, uint8 self), incompatible (uint->bytes32), and signedness (int8->uint256) cases stay rejected -- confirmed against pinned solc and preserved in the model. Ground truth (real solc 0.8.35 / EVM, forge lane using-for-widen): widenReceiver(255)==256 (uint8 zero-extended, no truncation), widenReceiver(5) ==6, widenAddArg(1000,255)==1255. - SolidCore/Witness/UsingForWiden.lean: acceptance + 3 runtime witnesses + 3 over-accept reject guards (all #guard). Imported into SolidCore.lean. - tests/forge-harness/using-for-widen: src + Forge test + 3 solc-reject guards; manifest.json lane (forge + solc_rejects + solc_import + lean evals). Gate: full `lake build` green (1116 jobs, incl. FuelMonotonicity + all witnesses); harness --only using-for-widen: solc_rejects=ok forge=ok lean=ok. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> (cherry picked from commit 4e454abb91ea0bb8a386a5f345507324f07f9d45)
250 lines
10 KiB
250 lines
10 KiB