Improve YUL parsing on top level function

pull/949/head
Josselin 3 years ago
parent 58458df77e
commit 2f854e1be0
  1. 14
      slither/solc_parsing/yul/parse_yul.py

@ -137,7 +137,7 @@ class YulScope(metaclass=abc.ABCMeta):
@property @property
def compilation_unit(self) -> SlitherCompilationUnit: def compilation_unit(self) -> SlitherCompilationUnit:
return self._contract.compilation_unit return self._parent_func.compilation_unit
@property @property
def parent_func(self) -> Optional[Function]: def parent_func(self) -> Optional[Function]:
@ -714,14 +714,16 @@ def parse_yul_identifier(root: YulScope, _node: YulNode, ast: Dict) -> Optional[
return Identifier(YulBuiltin(name)) return Identifier(YulBuiltin(name))
# check function-scoped variables # check function-scoped variables
if root.parent_func: parent_func = root.parent_func
variable = root.parent_func.get_local_variable_from_name(name) if parent_func:
variable = parent_func.get_local_variable_from_name(name)
if variable: if variable:
return Identifier(variable) return Identifier(variable)
variable = root.parent_func.contract.get_state_variable_from_name(name) if isinstance(parent_func, FunctionContract):
if variable: variable = parent_func.contract.get_state_variable_from_name(name)
return Identifier(variable) if variable:
return Identifier(variable)
# check yul-scoped variable # check yul-scoped variable
variable = root.get_yul_local_variable_from_name(name) variable = root.get_yul_local_variable_from_name(name)

Loading…
Cancel
Save