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

@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.

@cats2101
Copy link
Copy Markdown
Author

Gentle ping — anything else needed here?

Only skip the is_shadowed check when resolving via IdentifierPath
(e.g. A.m in a modifier reference), preserving existing behavior for
regular identifier lookups where shadowed functions should fall through
to virtual resolution.

Fixes crytic#2838
@cats2101 cats2101 force-pushed the fix/modifier-identifier-path-shadowed branch from be3cb25 to 53124e6 Compare April 12, 2026 12:28
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