Merge branch 'dev' of github.com:crytic/slither into dev

pull/1559/head^2
Josselin Feist 2 years ago
commit 7067c6d8eb
  1. 7
      slither/solc_parsing/slither_compilation_unit_solc.py
  2. BIN
      tests/ast-parsing/compile/top-level-struct-0.8.0.sol-0.8.0-compact.zip
  3. 3
      tests/ast-parsing/expected/top-level-struct-0.8.0.sol-0.8.0-compact.json
  4. 18
      tests/ast-parsing/top-level-struct-0.8.0.sol
  5. 1
      tests/test_ast_parsing.py

@ -24,6 +24,7 @@ from slither.solc_parsing.declarations.function import FunctionSolc
from slither.solc_parsing.declarations.structure_top_level import StructureTopLevelSolc from slither.solc_parsing.declarations.structure_top_level import StructureTopLevelSolc
from slither.solc_parsing.exceptions import VariableNotFound from slither.solc_parsing.exceptions import VariableNotFound
from slither.solc_parsing.variables.top_level_variable import TopLevelVariableSolc from slither.solc_parsing.variables.top_level_variable import TopLevelVariableSolc
from slither.solc_parsing.declarations.caller_context import CallerContextExpression
logging.basicConfig() logging.basicConfig()
logger = logging.getLogger("SlitherSolcParsing") logger = logging.getLogger("SlitherSolcParsing")
@ -57,7 +58,7 @@ def _handle_import_aliases(
scope.renaming[local_name] = original_name scope.renaming[local_name] = original_name
class SlitherCompilationUnitSolc: class SlitherCompilationUnitSolc(CallerContextExpression):
# pylint: disable=no-self-use,too-many-instance-attributes # pylint: disable=no-self-use,too-many-instance-attributes
def __init__(self, compilation_unit: SlitherCompilationUnit): def __init__(self, compilation_unit: SlitherCompilationUnit):
super().__init__() super().__init__()
@ -95,6 +96,10 @@ class SlitherCompilationUnitSolc:
def underlying_contract_to_parser(self) -> Dict[Contract, ContractSolc]: def underlying_contract_to_parser(self) -> Dict[Contract, ContractSolc]:
return self._underlying_contract_to_parser return self._underlying_contract_to_parser
@property
def slither_parser(self) -> "SlitherCompilationUnitSolc":
return self
################################################################################### ###################################################################################
################################################################################### ###################################################################################
# region AST # region AST

@ -0,0 +1,18 @@
struct my_struct {
uint[][] a; // works fine
uint[][3] b; // works fine
uint[3][] c; // fails
uint[3][3] d; // fails
uint[2**20] e; // works fine
}
contract BaseContract{
struct my_struct_2 {
uint[][] f; // works fine
uint[][3] g; // works fine
uint[3][] h; // works fine
uint[3][3] i; // works fine
uint[2**20] j; // works fine
}
uint[3][] k; // works fine
}

@ -425,6 +425,7 @@ ALL_TESTS = [
Test("free_functions/library_constant_function_collision.sol", ["0.8.12"]), Test("free_functions/library_constant_function_collision.sol", ["0.8.12"]),
Test("ternary-with-max.sol", ["0.8.15"]), Test("ternary-with-max.sol", ["0.8.15"]),
Test("library_event-0.8.16.sol", ["0.8.16"]), Test("library_event-0.8.16.sol", ["0.8.16"]),
Test("top-level-struct-0.8.0.sol", ["0.8.0"]),
] ]
# create the output folder if needed # create the output folder if needed
try: try:

Loading…
Cancel
Save