Skip to content

Check super calls and modifier invocations in every derived contract - #16932

Draft
msooseth wants to merge 1 commit into
developfrom
fix-view-pure-super-derived
Draft

Check super calls and modifier invocations in every derived contract#16932
msooseth wants to merge 1 commit into
developfrom
fix-view-pure-super-derived

Conversation

@msooseth

Copy link
Copy Markdown
Contributor

The view/pure checker validated a function body only against the bases visible from the contract that declares it. But both super lookups and virtual modifier lookups are re-resolved per most-derived contract, so an inherited pure/view function could silently reach a more mutable target. For example, B.f declared pure type-checks against A.f, yet under the linearization [D, B, X, A] its super.f() resolves to the storage-writing X.f; likewise a pure function using a virtual modifier that a derived contract overrides with a storage-writing one passed unnoticed.

ViewPureChecker now builds a map from each contract to the contracts that inherit it, and for every super function call and every modifier invocation re-resolves the target in each derived contract, reporting the new errors 7898 and 1614 when the resolved target is more mutable than the enclosing function.

Note: Three SMT checker modifier-overriding tests relied on the previously accepted behaviour and drop the now-invalid view marker from the affected functions.

Fixes

#16930

The view/pure checker validated a function body only against the bases
visible from the contract that declares it. But both `super` lookups and
virtual modifier lookups are re-resolved per most-derived contract, so an
inherited `pure`/`view` function could silently reach a more mutable target.
For example, `B.f` declared `pure` type-checks against `A.f`, yet under the
linearization `[D, B, X, A]` its `super.f()` resolves to the storage-writing
`X.f`; likewise a `pure` function using a virtual modifier that a derived
contract overrides with a storage-writing one passed unnoticed.

`ViewPureChecker` now builds a map from each contract to the contracts that
inherit it, and for every `super` function call and every modifier invocation
re-resolves the target in each derived contract, reporting the new errors 7898
and 1614 when the resolved target is more mutable than the enclosing function.
Three SMT checker modifier-overriding tests relied on the previously accepted
behaviour and drop the now-invalid `view` marker from the affected functions.
@msooseth
msooseth force-pushed the fix-view-pure-super-derived branch from 504a8b3 to cf540dd Compare August 21, 2026 08:12
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.

1 participant