-
-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: iterator modification analysis (#3764)
this commit fixes several bugs with analysis of iterator modification in loops. to do so, it refactors the analysis code to track reads/writes more accurately, and uses analysis machinery instead of AST queries to perform the check. it enriches ExprInfo with an `attr` attribute, so this can be used to detect if an ExprInfo is derived from an `Attribute`. ExprInfo could be further enriched with `Subscript` info so that the Attribute/Subscript chain can be reliably recovered just from ExprInfos, especially in the future if other functions rely on being able to recover the attribute chain. this commit also modifies `validate_functions` so that it validates the functions in dependency (call graph traversal) order rather than the order they appear in the AST. refactors: - add `enter_for_loop()` context manager for convenience+clarity - remove `ExprInfo.attribute_chain`, it was too confusing - hide `ContractFunctionT` member variables (`_variable_reads`, `_variable_writes`, `_used_modules`) behind public-facing API - remove `get_root_varinfo()` in favor of a helper `_get_variable_access()` function which detects access on variable sub-members (e.g., structs).
- Loading branch information
1 parent
a3bc3eb
commit 7bdebbf
Showing
13 changed files
with
505 additions
and
216 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.