Skip to content

Commit

Permalink
Merge pull request #2118 from crytic/dev-fix-type-inference
Browse files Browse the repository at this point in the history
Prioritize checking canonical_name for type inference
  • Loading branch information
montyly authored Oct 12, 2023
2 parents 7d1da92 + c95b953 commit dab60e0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions slither/solc_parsing/solidity_types/type_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def _find_from_type_name( # pylint: disable=too-many-locals,too-many-branches,t
# all_enums = [c.enums for c in contracts]
# all_enums = [item for sublist in all_enums for item in sublist]
# all_enums += contract.slither.enums_top_level
var_type = next((e for e in all_enums if e.name == enum_name), None)
var_type = next((e for e in all_enums if e.canonical_name == enum_name), None)
if not var_type:
var_type = next((e for e in all_enums if e.canonical_name == enum_name), None)
var_type = next((e for e in all_enums if e.name == enum_name), None)
if not var_type:
# any contract can refer to another contract's structure
name_struct = name
Expand All @@ -94,9 +94,9 @@ def _find_from_type_name( # pylint: disable=too-many-locals,too-many-branches,t
# all_structures = [c.structures for c in contracts]
# all_structures = [item for sublist in all_structures for item in sublist]
# all_structures += contract.slither.structures_top_level
var_type = next((st for st in all_structures if st.name == name_struct), None)
var_type = next((st for st in all_structures if st.canonical_name == name_struct), None)
if not var_type:
var_type = next((st for st in all_structures if st.canonical_name == name_struct), None)
var_type = next((st for st in all_structures if st.name == name_struct), None)
# case where struct xxx.xx[] where not well formed in the AST
if not var_type:
depth = 0
Expand Down

0 comments on commit dab60e0

Please sign in to comment.