Check super calls and modifier invocations in every derived contract - #16932
Draft
msooseth wants to merge 1 commit into
Draft
Check super calls and modifier invocations in every derived contract#16932msooseth wants to merge 1 commit into
super calls and modifier invocations in every derived contract#16932msooseth wants to merge 1 commit into
Conversation
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
force-pushed
the
fix-view-pure-super-derived
branch
from
August 21, 2026 08:12
504a8b3 to
cf540dd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The view/pure checker validated a function body only against the bases visible from the contract that declares it. But both
superlookups and virtual modifier lookups are re-resolved per most-derived contract, so an inheritedpure/viewfunction could silently reach a more mutable target. For example,B.fdeclaredpuretype-checks againstA.f, yet under the linearization[D, B, X, A]itssuper.f()resolves to the storage-writingX.f; likewise apurefunction using a virtual modifier that a derived contract overrides with a storage-writing one passed unnoticed.ViewPureCheckernow builds a map from each contract to the contracts that inherit it, and for everysuperfunction 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
viewmarker from the affected functions.Fixes
#16930