Repository navigation
Rebase mined getter invariants onto the receiver's field path - #5087
Open
wodex1nhaoIeng wants to merge 1 commit into
Open
wodex1nhaoIeng wants to merge 1 commit into
wodex1nhaoIeng wants to merge 1 commit into
Conversation
Mining a getter call such as `self.inner.valid()` treated `&self.inner` as `&self`, so the callee's field reads (e.g. `self.count`, field 0 of `Inner`) were interpreted as fields of the outer type. Compute the field path from the caller's `self` to the getter receiver and prepend it to the callee's mined expression; bail out on projections the expression AST cannot represent. Resolves model-checking#5011 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
--check-invariantschecked the wrong field when an invariant was mined through a getter called on a field ofself. In #5011,Outer::firstassertsself.inner.valid(), andInner::validchecksself.count > 0. The miner accepted&self.inneras if it were&self, then read the callee'sself.count(field 0 ofInner) as field 0 ofOuter, which isdecoy. The mined invariant becamedecoy > 0, somake_validfailed andmake_invalidpassed: the opposite of the correct verdicts.The getter's receiver can now be
selfor any field path under it. The miner records the field path from the caller'sselfto the receiver and prepends it to the expression mined from the callee, soInner::validturns intoself.inner.count > 0onOuter. Nested getters compose, since each level rebases onto its own caller. Receivers this AST can't express (a deref below a field, or a downcast under the prefix) make the miner skip the conjunct instead of guessing.One shape that isn't explicitly guarded against: a receiver field that is itself a reference or
Box, where the prefix would end at a pointer-typed field. On the current toolchain it can't reach the miner. rustc passesself.rthrough a reborrowed temp, which isn't rooted atself, and aBoxderef lowers toBoxDerefTransmute, which the extractor rejects. I left it at that rather than adding a guard for MIR that isn't produced today.Resolves #5011
The regression test
script-based-pre/autoharness_nested_getteris the reproducer from the issue plus a two-level receiver (Deep.outer.inner). It fails onmainand passes with this change. All 43 autoharness tests inscript-based-prepass, andrustfmt --checkis clean on the changed file.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.