fix: update register_printer to handle multiple compilation units#3025
Open
sulphur-swarm wants to merge 1 commit into
Open
fix: update register_printer to handle multiple compilation units#3025sulphur-swarm wants to merge 1 commit into
sulphur-swarm wants to merge 1 commit into
Conversation
…ytic#1780) register_detector iterates over self.compilation_units to create one detector instance per compilation unit. register_printer was missing this loop, creating a single instance regardless of the number of compilation units. Update register_printer to mirror register_detector by wrapping instantiation in a for-loop over self.compilation_units. Also update AbstractPrinter.__init__ to accept a compilation_unit parameter (mirroring AbstractDetector), and update unregister_printer to remove all instances of a given printer class (not just the first), since multiple instances may now be registered. Fixes: crytic#1780
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.
Summary
Fixes #1780.
register_detectoralready iterates overself.compilation_unitsto create one detector instance per compilation unit.register_printerwas missing this loop — it unconditionally created a single printer instance regardless of how many compilation units exist.Changes
slither/slither.py: Wrap printer instantiation inregister_printerin afor compilation_unit in self.compilation_units:loop, mirroring the pattern used byregister_detector.slither/printers/abstract_printer.py: UpdateAbstractPrinter.__init__to accept acompilation_unitparameter as the first argument (mirroringAbstractDetector), and setself.contracts = compilation_unit.contractsinstead ofslither.contracts.slither/printers/inheritance/inheritance_graph.py: UpdatePrinterInheritanceGraph.__init__to pass the compilation unit through tosuper().__init__().tests/e2e/printers/test_printers.py: Update tests to useregister_printerinstead of direct instantiation, which is the correct API.Before
After
This fix was contributed with AI assistance by SwarmFix (sulphur-swarm).