Skip to content

fix: resolve shadowed modifiers via IdentifierPath#2992

Open
cats2101 wants to merge 1 commit intocrytic:masterfrom
cats2101:fix/modifier-identifier-path-shadowed
Open

fix: resolve shadowed modifiers via IdentifierPath#2992
cats2101 wants to merge 1 commit intocrytic:masterfrom
cats2101:fix/modifier-identifier-path-shadowed

Conversation

@cats2101
Copy link
Copy Markdown

Summary

Fixes #2838

When a modifier is referenced via IdentifierPath (e.g. A.m in function f() public A.m), the compiler resolves the exact declaration id via referencedDeclaration. However, _find_variable_from_ref_declaration was filtering out matches where is_shadowed is true — which incorrectly rejected parent modifiers that are overridden by a child contract.

Since referencedDeclaration is the compiler's authoritative resolution, we should trust it without filtering by is_shadowed. The shadowed filter is appropriate for name-based lookups (where you want the most-derived version), but not when looking up by compiler-resolved id.

Before

ERROR:ContractSolcParsing:Missing function Variable not found: A.m (context C)

After

Parses correctly, no error.

Reproducer

contract A {
    modifier m() virtual { _; }
}

contract C is A {
    modifier m() override { _; }
    function f() public A.m returns (uint) { return 1; }
}

Test plan

When a modifier is referenced via IdentifierPath (e.g. A.m in
'function f() public A.m'), the compiler resolves the exact
declaration id. The is_shadowed filter in _find_variable_from_ref_declaration
incorrectly rejected these because the parent modifier is marked
shadowed by the overriding child.

Since referencedDeclaration is the compiler's authoritative resolution,
we should trust it without filtering by is_shadowed.

Closes crytic#2838
@cats2101 cats2101 requested a review from smonicas as a code owner March 31, 2026 22:14
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 31, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug-Candidate]: Slither is unable to locate the Modifier referenced in the IdentifierPath format.

2 participants