From 697e7bab46fd61c0de375d9188c62bf463430119 Mon Sep 17 00:00:00 2001 From: Josselin Date: Sun, 19 Jul 2020 16:04:31 +0200 Subject: [PATCH] Improve support for variable name reused (fix #534) --- slither/solc_parsing/declarations/function.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index 1bffc1fd7..a61bc2b6c 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -148,11 +148,13 @@ class FunctionSolc: # Use of while in case of collision # In the worst case, the name will be really long if local_var_parser.underlying_variable.name: - while local_var_parser.underlying_variable.name in self._function.variables: + known_variables = [v.name for v in self._function.variables] + while local_var_parser.underlying_variable.name in known_variables: local_var_parser.underlying_variable.name += "_scope_{}".format( self._counter_scope_local_variables ) self._counter_scope_local_variables += 1 + known_variables = [v.name for v in self._function.variables] if local_var_parser.reference_id is not None: self._variables_renamed[local_var_parser.reference_id] = local_var_parser self._function.variables_as_dict[