track type aliases at top level

pull/1579/head
alpharush 2 years ago
parent ceba99f48e
commit 78caeb691c
  1. 6
      slither/core/compilation_unit.py
  2. 1
      slither/solc_parsing/slither_compilation_unit_solc.py
  3. 2
      slither/solc_parsing/solidity_types/type_parsing.py

@ -18,6 +18,7 @@ from slither.core.declarations.enum_top_level import EnumTopLevel
from slither.core.declarations.function_top_level import FunctionTopLevel
from slither.core.declarations.using_for_top_level import UsingForTopLevel
from slither.core.declarations.structure_top_level import StructureTopLevel
from slither.core.solidity_types.type_alias import TypeAliasTopLevel
from slither.core.scope.scope import FileScope
from slither.core.variables.state_variable import StateVariable
from slither.core.variables.top_level_variable import TopLevelVariable
@ -46,6 +47,7 @@ class SlitherCompilationUnit(Context):
self._pragma_directives: List[Pragma] = []
self._import_directives: List[Import] = []
self._custom_errors: List[CustomError] = []
self._user_defined_value_types: Dict[str, TypeAliasTopLevel] = {}
self._all_functions: Set[Function] = set()
self._all_modifiers: Set[Modifier] = set()
@ -215,6 +217,10 @@ class SlitherCompilationUnit(Context):
def custom_errors(self) -> List[CustomError]:
return self._custom_errors
@property
def user_defined_value_types(self) -> Dict[str, TypeAliasTopLevel]:
return self._user_defined_value_types
# endregion
###################################################################################
###################################################################################

@ -330,6 +330,7 @@ class SlitherCompilationUnitSolc(CallerContextExpression):
user_defined_type = TypeAliasTopLevel(original_type, alias, scope)
user_defined_type.set_offset(top_level_data["src"], self._compilation_unit)
self._compilation_unit.user_defined_value_types[alias] = user_defined_type
scope.user_defined_types[alias] = user_defined_type
else:

@ -243,7 +243,7 @@ def parse_type(
sl = caller_context.compilation_unit
next_context = caller_context
renaming = {}
user_defined_types = {}
user_defined_types = sl.user_defined_value_types
else:
assert isinstance(caller_context, FunctionSolc)
sl = caller_context.underlying_function.compilation_unit

Loading…
Cancel
Save