Merge pull request #538 from crytic/dev-duplicate-index

Improve support for variable name reused
pull/539/head
Feist Josselin 4 years ago committed by GitHub
commit 9e69274e45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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