mirror of
https://github.com/paradigmxyz/solidity-lean.git
synced 2026-11-15 19:56:39 +00:00
the NAMED base contract's own modifier (solc `VirtualLookup::Static`), NOT the
most-derived override. In the pinned solc 0.8.35 AST the invocation is an
`IdentifierPath name:"Base.m"` whose `referencedDeclaration` is Base's
ModifierDefinition (id 11), not Derived's override (id 33); deploying Derived
and calling `f()` leaves `tag == 1` on the real EVM (anvil confirmed).
The model dropped the qualifier: every modifier invocation resolved by its LAST
path segment (`pathLast?`) via first-match (`find?`) over the most-derived-first
dispatch order, so `Base.m` wrongly ran Derived's `m` (`tag == 2`).
Fix: carry the declaring contract on each modifier and resolve a qualified
target statically against it.
- `ModifierDecl.declaringContract : Option Name` (Ast.lean), stamped by the
new `ContractDecl.directModifiersStamped` at both whole-contract modifier-
list build sites (Interface.lean).
- `modifierResolve?` replaces `pathLast? + modifierFindByName?` at all five
modifier-expansion sites: an UNQUALIFIED single-segment target stays VIRTUAL
(first name match = most-derived override, unchanged); a QUALIFIED target
binds to the contract named by the qualifier segment, falling back to the
virtual lookup if no stamped match (no path regresses).
Witness `SolidCore/Witness/ModifierStaticQualifier.lean` (imported from
SolidCore.lean): qualified `Base.m` -> tag==1, unqualified control -> tag==2.
Forge lane `tests/forge-harness/modifier-static-qualifier` (+ manifest entry)
gives real-EVM ground truth for both and imports the same unit from the solc
AST through static resolution.
Full `lake build` green (1116 jobs); forge lane green (2 passed); harness
`forge=ok lean=ok forge_interpreter_compare=pass`.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit b99b84f4c0b601ee56e0e9ff6fe05b0f74438363)
140 lines
5 KiB
140 lines
5 KiB