Repository navigation
Conversation
`apply_mutant` looked the target up by its bare name and took the first top-level function or method with that name, so a mutant of a top-level `size` could overwrite `Box.size`. Look it up by the class name in the mutant key instead, using a separate helper because `read_original_function` relies on the old lookup. Based on the fix suggested in boxed#624 by Ivan Balashov. Fixes boxed#624 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
mutmut applylooked up the function to replace by its bare name and took the first top-level function or method with that name, so applying a mutant of a top-levelsizecould overwriteBox.sizewhen the class came first in the module. The class name is already in the mutant key, soapply_mutantnow passes it to a newfind_functionhelper that searches that class's methods, or only top-level functions when the key has no class. It's a separate helper becauseread_original_functionandread_mutant_functionlook up the generated names, which already include the class, somutmut showand thebrowsediff were never affected. It follows the snippet Ivan Balashov suggested in the issue, thanks for the clear report. The new test applies a mutant of a top-level function and of the methods of two classes that share the namesize, with and without the line span index, and checks that only the right function changes. I also ranmutmut run,mutmut applyandmutmut showon the repro from the issue for both mutant keys.Fixes #624