Improve support for variable name reused (fix #534)

pull/538/head
Josselin 4 years ago
parent c857bf88fd
commit 697e7bab46
  1. 4
      slither/solc_parsing/declarations/function.py

@ -148,11 +148,13 @@ class FunctionSolc:
# Use of while in case of collision # Use of while in case of collision
# In the worst case, the name will be really long # In the worst case, the name will be really long
if local_var_parser.underlying_variable.name: 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( local_var_parser.underlying_variable.name += "_scope_{}".format(
self._counter_scope_local_variables self._counter_scope_local_variables
) )
self._counter_scope_local_variables += 1 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: if local_var_parser.reference_id is not None:
self._variables_renamed[local_var_parser.reference_id] = local_var_parser self._variables_renamed[local_var_parser.reference_id] = local_var_parser
self._function.variables_as_dict[ self._function.variables_as_dict[

Loading…
Cancel
Save