diff --git a/slither/core/compilation_unit.py b/slither/core/compilation_unit.py index 293474778..693eff821 100644 --- a/slither/core/compilation_unit.py +++ b/slither/core/compilation_unit.py @@ -13,6 +13,7 @@ from slither.core.declarations import ( Function, Modifier, ) +from slither.core.declarations.custom_error import CustomError from slither.core.declarations.enum_top_level import EnumTopLevel from slither.core.declarations.function_top_level import FunctionTopLevel from slither.core.declarations.structure_top_level import StructureTopLevel @@ -40,6 +41,7 @@ class SlitherCompilationUnit(Context): self._functions_top_level: List[FunctionTopLevel] = [] self._pragma_directives: List[Pragma] = [] self._import_directives: List[Import] = [] + self._custom_errors: List[CustomError] = [] self._all_functions: Set[Function] = set() self._all_modifiers: Set[Modifier] = set() @@ -210,6 +212,10 @@ class SlitherCompilationUnit(Context): def functions_top_level(self) -> List[FunctionTopLevel]: return self._functions_top_level + @property + def custom_errors(self) -> List[CustomError]: + return self._custom_errors + # endregion ################################################################################### ################################################################################### diff --git a/slither/core/declarations/contract.py b/slither/core/declarations/contract.py index 08279246a..4fc274dea 100644 --- a/slither/core/declarations/contract.py +++ b/slither/core/declarations/contract.py @@ -38,6 +38,7 @@ if TYPE_CHECKING: from slither.core.variables.variable import Variable from slither.core.variables.state_variable import StateVariable from slither.core.compilation_unit import SlitherCompilationUnit + from slither.core.declarations.custom_error_contract import CustomErrorContract LOGGER = logging.getLogger("Contract") @@ -68,6 +69,7 @@ class Contract(SourceMapping): # pylint: disable=too-many-public-methods self._modifiers: Dict[str, "Modifier"] = {} self._functions: Dict[str, "FunctionContract"] = {} self._linearizedBaseContracts: List[int] = [] + self._custom_errors: Dict[str:"CustomErrorContract"] = {} # The only str is "*" self._using_for: Dict[Union[str, Type], List[str]] = {} @@ -242,6 +244,38 @@ class Contract(SourceMapping): # pylint: disable=too-many-public-methods def using_for(self) -> Dict[Union[str, Type], List[str]]: return self._using_for + # endregion + ################################################################################### + ################################################################################### + # region Custom Errors + ################################################################################### + ################################################################################### + + @property + def custom_errors(self) -> List["CustomErrorContract"]: + """ + list(CustomErrorContract): List of the contract's custom errors + """ + return list(self._custom_errors.values()) + + @property + def custom_errors_inherited(self) -> List["CustomErrorContract"]: + """ + list(CustomErrorContract): List of the inherited custom errors + """ + return [s for s in self.custom_errors if s.contract != self] + + @property + def custom_errors_declared(self) -> List["CustomErrorContract"]: + """ + list(CustomErrorContract): List of the custom errors declared within the contract (not inherited) + """ + return [s for s in self.custom_errors if s.contract == self] + + @property + def custom_errors_as_dict(self) -> Dict[str, "CustomErrorContract"]: + return self._custom_errors + # endregion ################################################################################### ################################################################################### diff --git a/slither/core/declarations/custom_error.py b/slither/core/declarations/custom_error.py new file mode 100644 index 000000000..fc2066982 --- /dev/null +++ b/slither/core/declarations/custom_error.py @@ -0,0 +1,71 @@ +from typing import List, TYPE_CHECKING, Optional, Type, Union + +from slither.core.solidity_types import UserDefinedType +from slither.core.source_mapping.source_mapping import SourceMapping +from slither.core.variables.local_variable import LocalVariable + +if TYPE_CHECKING: + from slither.core.compilation_unit import SlitherCompilationUnit + + +class CustomError(SourceMapping): + def __init__(self, compilation_unit: "SlitherCompilationUnit"): + super().__init__() + self._name: str = "" + self._parameters: List[LocalVariable] = [] + self._compilation_unit = compilation_unit + + self._solidity_signature: Optional[str] = None + + @property + def name(self) -> str: + return self._name + + @name.setter + def name(self, new_name: str) -> None: + self._name = new_name + + @property + def parameters(self) -> List[LocalVariable]: + return self._parameters + + def add_parameters(self, p: "LocalVariable"): + self._parameters.append(p) + + @property + def compilation_unit(self) -> "SlitherCompilationUnit": + return self._compilation_unit + + # region Signature + ################################################################################### + ################################################################################### + + @staticmethod + def _convert_type_for_solidity_signature(t: Optional[Union[Type, List[Type]]]): + # pylint: disable=import-outside-toplevel + from slither.core.declarations import Contract + + if isinstance(t, UserDefinedType) and isinstance(t.type, Contract): + return "address" + return str(t) + + @property + def solidity_signature(self) -> str: + """ + Return a signature following the Solidity Standard + Contract and converted into address + :return: the solidity signature + """ + if self._solidity_signature is None: + parameters = [ + self._convert_type_for_solidity_signature(x.type) for x in self.parameters + ] + self._solidity_signature = self.name + "(" + ",".join(parameters) + ")" + return self._solidity_signature + + # endregion + ################################################################################### + ################################################################################### + + def __str__(self): + return "revert " + self.solidity_signature diff --git a/slither/core/declarations/custom_error_contract.py b/slither/core/declarations/custom_error_contract.py new file mode 100644 index 000000000..a96f12057 --- /dev/null +++ b/slither/core/declarations/custom_error_contract.py @@ -0,0 +1,12 @@ +from slither.core.children.child_contract import ChildContract +from slither.core.declarations.custom_error import CustomError + + +class CustomErrorContract(CustomError, ChildContract): + def is_declared_by(self, contract): + """ + Check if the element is declared by the contract + :param contract: + :return: + """ + return self.contract == contract diff --git a/slither/core/declarations/custom_error_top_level.py b/slither/core/declarations/custom_error_top_level.py new file mode 100644 index 000000000..f6463a528 --- /dev/null +++ b/slither/core/declarations/custom_error_top_level.py @@ -0,0 +1,6 @@ +from slither.core.declarations.custom_error import CustomError +from slither.core.declarations.top_level import TopLevel + + +class CustomErrorTopLevel(CustomError, TopLevel): + pass diff --git a/slither/core/declarations/solidity_variables.py b/slither/core/declarations/solidity_variables.py index 5a2218d18..4ae49c014 100644 --- a/slither/core/declarations/solidity_variables.py +++ b/slither/core/declarations/solidity_variables.py @@ -2,6 +2,7 @@ from typing import List, Dict, Union, TYPE_CHECKING from slither.core.context.context import Context +from slither.core.declarations.custom_error import CustomError from slither.core.solidity_types import ElementaryType, TypeInformation from slither.exceptions import SlitherException @@ -42,6 +43,7 @@ SOLIDITY_FUNCTIONS: Dict[str, List[str]] = { "require(bool,string)": [], "revert()": [], "revert(string)": [], + "revert ": [], "addmod(uint256,uint256,uint256)": ["uint256"], "mulmod(uint256,uint256,uint256)": ["uint256"], "keccak256()": ["bytes32"], @@ -184,3 +186,20 @@ class SolidityFunction: def __hash__(self): return hash(self.name) + + +class SolidityCustomRevert(SolidityFunction): + def __init__(self, custom_error: CustomError): # pylint: disable=super-init-not-called + self._name = "revert " + custom_error.solidity_signature + self._custom_error = custom_error + self._return_type: List[Union[TypeInformation, ElementaryType]] = [] + + def __eq__(self, other): + return ( + self.__class__ == other.__class__ + and self.name == other.name + and self._custom_error == other._custom_error + ) + + def __hash__(self): + return hash(hash(self.name) + hash(self._custom_error)) diff --git a/slither/printers/inheritance/inheritance.py b/slither/printers/inheritance/inheritance.py index f487be73d..08c05f95f 100644 --- a/slither/printers/inheritance/inheritance.py +++ b/slither/printers/inheritance/inheritance.py @@ -30,9 +30,6 @@ class PrinterInheritance(AbstractPrinter): """ info = "Inheritance\n" - if not self.contracts: - return [] - info += blue("Child_Contract -> ") + green("Immediate_Base_Contracts") info += green(" [Not_Immediate_Base_Contracts]") diff --git a/slither/slithir/convert.py b/slither/slithir/convert.py index b9bc85c70..a3b948626 100644 --- a/slither/slithir/convert.py +++ b/slither/slithir/convert.py @@ -13,8 +13,10 @@ from slither.core.declarations import ( SolidityVariableComposed, Structure, ) +from slither.core.declarations.custom_error import CustomError from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.solidity_import_placeholder import SolidityImportPlaceHolder +from slither.core.declarations.solidity_variables import SolidityCustomRevert from slither.core.expressions import Identifier, Literal from slither.core.solidity_types import ( ArrayType, @@ -941,6 +943,12 @@ def extract_tmp_call(ins: TmpCall, contract: Optional[Contract]): # pylint: dis s.set_expression(ins.expression) return s + if isinstance(ins.called, CustomError): + sol_function = SolidityCustomRevert(ins.called) + s = SolidityCall(sol_function, ins.nbr_arguments, ins.lvalue, ins.type_call) + s.set_expression(ins.expression) + return s + if isinstance(ins.ori, TmpNewElementaryType): n = NewElementaryType(ins.ori.type, ins.lvalue) n.set_expression(ins.expression) diff --git a/slither/slithir/tmp_operations/tmp_call.py b/slither/slithir/tmp_operations/tmp_call.py index 2157d0323..adb461e50 100644 --- a/slither/slithir/tmp_operations/tmp_call.py +++ b/slither/slithir/tmp_operations/tmp_call.py @@ -5,6 +5,7 @@ from slither.core.declarations import ( SolidityFunction, Structure, ) +from slither.core.declarations.custom_error import CustomError from slither.core.variables.variable import Variable from slither.slithir.operations.lvalue import OperationWithLValue @@ -20,6 +21,7 @@ class TmpCall(OperationWithLValue): # pylint: disable=too-many-instance-attribu SolidityFunction, Structure, Event, + CustomError, ), ) super().__init__() diff --git a/slither/solc_parsing/declarations/contract.py b/slither/solc_parsing/declarations/contract.py index dde0053c4..dba0bf771 100644 --- a/slither/solc_parsing/declarations/contract.py +++ b/slither/solc_parsing/declarations/contract.py @@ -3,8 +3,10 @@ from typing import List, Dict, Callable, TYPE_CHECKING, Union, Set from slither.core.declarations import Modifier, Event, EnumContract, StructureContract, Function from slither.core.declarations.contract import Contract +from slither.core.declarations.custom_error_contract import CustomErrorContract from slither.core.declarations.function_contract import FunctionContract from slither.core.variables.state_variable import StateVariable +from slither.solc_parsing.declarations.custom_error import CustomErrorSolc from slither.solc_parsing.declarations.event import EventSolc from slither.solc_parsing.declarations.function import FunctionSolc from slither.solc_parsing.declarations.modifier import ModifierSolc @@ -35,15 +37,17 @@ class ContractSolc: self._modifiersNotParsed: List[Dict] = [] self._functions_no_params: List[FunctionSolc] = [] self._modifiers_no_params: List[ModifierSolc] = [] - self._eventsNotParsed: List[EventSolc] = [] + self._eventsNotParsed: List[Dict] = [] self._variablesNotParsed: List[Dict] = [] self._enumsNotParsed: List[Dict] = [] self._structuresNotParsed: List[Dict] = [] self._usingForNotParsed: List[Dict] = [] + self._customErrorParsed: List[Dict] = [] self._functions_parser: List[FunctionSolc] = [] self._modifiers_parser: List[ModifierSolc] = [] self._structures_parser: List[StructureContractSolc] = [] + self._custom_errors_parser: List[CustomErrorSolc] = [] self._is_analyzed: bool = False @@ -246,6 +250,8 @@ class ContractSolc: self._structuresNotParsed.append(item) elif item[self.get_key()] == "UsingForDirective": self._usingForNotParsed.append(item) + elif item[self.get_key()] == "ErrorDefinition": + self._customErrorParsed.append(item) else: raise ParsingError("Unknown contract item: " + item[self.get_key()]) return @@ -268,6 +274,23 @@ class ContractSolc: self._parse_struct(struct) self._structuresNotParsed = None + def _parse_custom_error(self, custom_error: Dict): + ce = CustomErrorContract(self.compilation_unit) + ce.set_contract(self._contract) + ce.set_offset(custom_error["src"], self.compilation_unit) + + ce_parser = CustomErrorSolc(ce, custom_error, self._slither_parser) + self._contract.custom_errors_as_dict[ce.name] = ce + self._custom_errors_parser.append(ce_parser) + + def parse_custom_errors(self): + for father in self._contract.inheritance_reverse: + self._contract.custom_errors_as_dict.update(father.custom_errors_as_dict) + + for custom_error in self._customErrorParsed: + self._parse_custom_error(custom_error) + self._customErrorParsed = None + def parse_state_variables(self): for father in self._contract.inheritance_reverse: self._contract.variables_as_dict.update(father.variables_as_dict) @@ -600,6 +623,10 @@ class ContractSolc: except (VariableNotFound, KeyError) as e: self.log_incorrect_parsing(f"Missing struct {e}") + def analyze_custom_errors(self): + for custom_error in self._custom_errors_parser: + custom_error.analyze_params() + def analyze_events(self): try: for father in self._contract.inheritance_reverse: @@ -640,6 +667,7 @@ class ContractSolc: self._enumsNotParsed = [] self._structuresNotParsed = [] self._usingForNotParsed = [] + self._customErrorParsed = [] # endregion ################################################################################### diff --git a/slither/solc_parsing/declarations/custom_error.py b/slither/solc_parsing/declarations/custom_error.py new file mode 100644 index 000000000..417e5bc52 --- /dev/null +++ b/slither/solc_parsing/declarations/custom_error.py @@ -0,0 +1,101 @@ +from typing import TYPE_CHECKING, Dict + +from slither.core.declarations.custom_error import CustomError +from slither.core.variables.local_variable import LocalVariable +from slither.solc_parsing.variables.local_variable import LocalVariableSolc + +if TYPE_CHECKING: + from slither.solc_parsing.slither_compilation_unit_solc import SlitherCompilationUnitSolc + + +# Part of the code was copied from the function parsing +# In the long term we should refactor these two classes to merge the duplicated code + + +class CustomErrorSolc: + def __init__( + self, + custom_error: CustomError, + custom_error_data: dict, + slither_parser: "SlitherCompilationUnitSolc", + ): + self._slither_parser: "SlitherCompilationUnitSolc" = slither_parser + self._custom_error = custom_error + custom_error.name = custom_error_data["name"] + self._params_was_analyzed = False + + if not self._slither_parser.is_compact_ast: + custom_error_data = custom_error_data["attributes"] + self._custom_error_data = custom_error_data + + def analyze_params(self): + # Can be re-analyzed due to inheritance + if self._params_was_analyzed: + return + + self._params_was_analyzed = True + + if self._slither_parser.is_compact_ast: + params = self._custom_error_data["parameters"] + else: + children = self._custom_error_data[self.get_children("children")] + # It uses to be + # params = children[0] + # returns = children[1] + # But from Solidity 0.6.3 to 0.6.10 (included) + # Comment above a function might be added in the children + child_iter = iter( + [child for child in children if child[self.get_key()] == "ParameterList"] + ) + params = next(child_iter) + + if params: + self._parse_params(params) + + @property + def is_compact_ast(self) -> bool: + return self._slither_parser.is_compact_ast + + def get_key(self) -> str: + return self._slither_parser.get_key() + + def get_children(self, key: str) -> str: + if self._slither_parser.is_compact_ast: + return key + return "children" + + def _parse_params(self, params: Dict): + assert params[self.get_key()] == "ParameterList" + + if self._slither_parser.is_compact_ast: + params = params["parameters"] + else: + params = params[self.get_children("children")] + + for param in params: + assert param[self.get_key()] == "VariableDeclaration" + local_var = self._add_param(param) + self._custom_error.add_parameters(local_var.underlying_variable) + + def _add_param(self, param: Dict) -> LocalVariableSolc: + + local_var = LocalVariable() + local_var.set_offset(param["src"], self._slither_parser.compilation_unit) + + local_var_parser = LocalVariableSolc(local_var, param) + + local_var_parser.analyze(self) + + # see https://solidity.readthedocs.io/en/v0.4.24/types.html?highlight=storage%20location#data-location + if local_var.location == "default": + local_var.set_location("memory") + + return local_var_parser + + @property + def underlying_custom_error(self) -> CustomError: + return self._custom_error + + @property + def slither_parser(self) -> "SlitherCompilationUnitSolc": + return self._slither_parser diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index c3f7d8fd9..4bc10f1ff 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -10,12 +10,11 @@ from slither.core.declarations.function import ( FunctionType, ) from slither.core.declarations.function_contract import FunctionContract - from slither.core.expressions import AssignmentOperation from slither.core.variables.local_variable import LocalVariable from slither.core.variables.local_variable_init_from_tuple import LocalVariableInitFromTuple - from slither.solc_parsing.cfg.node import NodeSolc +from slither.solc_parsing.exceptions import ParsingError from slither.solc_parsing.expressions.expression_parsing import parse_expression from slither.solc_parsing.variables.local_variable import LocalVariableSolc from slither.solc_parsing.variables.local_variable_init_from_tuple import ( @@ -26,13 +25,11 @@ from slither.solc_parsing.yul.parse_yul import YulBlock from slither.utils.expression_manipulations import SplitTernaryExpression from slither.visitors.expression.export_values import ExportValues from slither.visitors.expression.has_conditional import HasConditional -from slither.solc_parsing.exceptions import ParsingError if TYPE_CHECKING: from slither.core.expressions.expression import Expression from slither.solc_parsing.declarations.contract import ContractSolc from slither.solc_parsing.slither_compilation_unit_solc import SlitherCompilationUnitSolc - from slither.core.slither_core import SlitherCore from slither.core.compilation_unit import SlitherCompilationUnit @@ -1012,6 +1009,15 @@ class FunctionSolc: node = self._parse_try_catch(statement, node) # elif name == 'TryCatchClause': # self._parse_catch(statement, node) + elif name == "RevertStatement": + if self.is_compact_ast: + expression = statement[self.get_children("errorCall")] + else: + expression = statement[self.get_children("errorCall")][0] + new_node = self._new_node(NodeType.EXPRESSION, statement["src"], scope) + new_node.add_unparsed_expression(expression) + link_underlying_nodes(node, new_node) + node = new_node else: raise ParsingError("Statement not parsed %s" % name) diff --git a/slither/solc_parsing/expressions/find_variable.py b/slither/solc_parsing/expressions/find_variable.py index 3edb29d98..a981db252 100644 --- a/slither/solc_parsing/expressions/find_variable.py +++ b/slither/solc_parsing/expressions/find_variable.py @@ -2,6 +2,7 @@ from typing import TYPE_CHECKING, Optional, Union, List, Tuple from slither.core.declarations import Event, Enum, Structure from slither.core.declarations.contract import Contract +from slither.core.declarations.custom_error import CustomError from slither.core.declarations.function import Function from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_top_level import FunctionTopLevel @@ -100,7 +101,7 @@ def _find_variable_in_function_parser( def _find_top_level( var_name: str, sl: "SlitherCompilationUnit" -) -> Tuple[Optional[Union[Enum, Structure, SolidityImportPlaceHolder]], bool]: +) -> Tuple[Optional[Union[Enum, Structure, SolidityImportPlaceHolder, CustomError]], bool]: """ Return the top level variable use, and a boolean indicating if the variable returning was cretead If the variable was created, it has no source_mapping @@ -127,6 +128,11 @@ def _find_top_level( new_val = SolidityImportPlaceHolder(import_directive) return new_val, True + # Note for now solidity prevent two custom error from having the same name + for custom_error in sl.custom_errors: + if custom_error.solidity_signature == var_name: + return custom_error, False + return None, False @@ -135,7 +141,7 @@ def _find_in_contract( contract: Optional[Contract], contract_declarer: Optional[Contract], is_super: bool, -) -> Optional[Union[Variable, Function, Contract, Event, Enum, Structure,]]: +) -> Optional[Union[Variable, Function, Contract, Event, Enum, Structure, CustomError]]: if contract is None or contract_declarer is None: return None @@ -191,6 +197,14 @@ def _find_in_contract( if var_name in enums: return enums[var_name] + # Note: contract.custom_errors_as_dict uses the name (not the sol sig) as key + # This is because when the dic is populated the underlying object is not yet parsed + # As a result, we need to iterate over all the custom errors here instead of using the dict + custom_errors = contract.custom_errors + for custom_error in custom_errors: + if var_name == custom_error.solidity_signature: + return custom_error + # If the enum is refered as its name rather than its canonicalName enums = {e.name: e for e in contract.enums} if var_name in enums: @@ -260,6 +274,7 @@ def find_variable( Event, Enum, Structure, + CustomError, ], bool, ]: @@ -384,4 +399,4 @@ def find_variable( if ret: return ret, False - raise VariableNotFound("Variable not found: {} (context {})".format(var_name, caller_context)) + raise VariableNotFound("Variable not found: {} (context {})".format(var_name, contract)) diff --git a/slither/solc_parsing/slither_compilation_unit_solc.py b/slither/solc_parsing/slither_compilation_unit_solc.py index 35c94e493..356b55db9 100644 --- a/slither/solc_parsing/slither_compilation_unit_solc.py +++ b/slither/solc_parsing/slither_compilation_unit_solc.py @@ -8,6 +8,7 @@ from typing import List, Dict from slither.analyses.data_dependency.data_dependency import compute_dependency from slither.core.compilation_unit import SlitherCompilationUnit from slither.core.declarations import Contract +from slither.core.declarations.custom_error_top_level import CustomErrorTopLevel from slither.core.declarations.enum_top_level import EnumTopLevel from slither.core.declarations.function_top_level import FunctionTopLevel from slither.core.declarations.import_directive import Import @@ -16,6 +17,7 @@ from slither.core.declarations.structure_top_level import StructureTopLevel from slither.core.variables.top_level_variable import TopLevelVariable from slither.exceptions import SlitherException from slither.solc_parsing.declarations.contract import ContractSolc +from slither.solc_parsing.declarations.custom_error import CustomErrorSolc from slither.solc_parsing.declarations.function import FunctionSolc from slither.solc_parsing.declarations.structure_top_level import StructureTopLevelSolc from slither.solc_parsing.exceptions import VariableNotFound @@ -37,6 +39,7 @@ class SlitherCompilationUnitSolc: self._underlying_contract_to_parser: Dict[Contract, ContractSolc] = dict() self._structures_top_level_parser: List[StructureTopLevelSolc] = [] + self._custom_error_parser: List[CustomErrorSolc] = [] self._variables_top_level_parser: List[TopLevelVariableSolc] = [] self._functions_top_level_parser: List[FunctionSolc] = [] @@ -146,7 +149,7 @@ class SlitherCompilationUnitSolc: def parse_top_level_from_loaded_json( self, data_loaded: Dict, filename: str - ): # pylint: disable=too-many-branches,too-many-statements + ): # pylint: disable=too-many-branches,too-many-statements,too-many-locals if "nodeType" in data_loaded: self._is_compact_ast = True @@ -164,6 +167,8 @@ class SlitherCompilationUnitSolc: logger.error("solc version is not supported") return + if self.get_children() not in data_loaded: + return for top_level_data in data_loaded[self.get_children()]: if top_level_data[self.get_key()] == "ContractDefinition": contract = Contract(self._compilation_unit) @@ -235,6 +240,14 @@ class SlitherCompilationUnitSolc: self._functions_top_level_parser.append(func_parser) self.add_function_or_modifier_parser(func_parser) + elif top_level_data[self.get_key()] == "ErrorDefinition": + custom_error = CustomErrorTopLevel(self._compilation_unit) + custom_error.set_offset(top_level_data["src"], self._compilation_unit) + + custom_error_parser = CustomErrorSolc(custom_error, top_level_data, self) + self._compilation_unit.custom_errors.append(custom_error) + self._custom_error_parser.append(custom_error_parser) + else: raise SlitherException(f"Top level {top_level_data[self.get_key()]} not supported") @@ -522,6 +535,7 @@ Please rename it, this name is reserved for Slither's internals""" contract.parse_state_variables() contract.parse_modifiers() contract.parse_functions() + contract.parse_custom_errors() contract.set_is_analyzed(True) def _analyze_struct_events(self, contract: ContractSolc): @@ -534,6 +548,7 @@ Please rename it, this name is reserved for Slither's internals""" contract.analyze_events() contract.analyze_using_for() + contract.analyze_custom_errors() contract.set_is_analyzed(True) @@ -556,6 +571,10 @@ Please rename it, this name is reserved for Slither's internals""" func_parser.analyze_params() self._compilation_unit.add_function(func_parser.underlying_function) + def _analyze_params_custom_error(self): + for custom_error_parser in self._custom_error_parser: + custom_error_parser.analyze_params() + def _analyze_content_top_level_function(self): try: for func_parser in self._functions_top_level_parser: @@ -569,6 +588,7 @@ Please rename it, this name is reserved for Slither's internals""" contract.analyze_params_modifiers() contract.analyze_params_functions() self._analyze_params_top_level_function() + self._analyze_params_custom_error() contract.analyze_state_variables() diff --git a/slither/solc_parsing/solidity_types/type_parsing.py b/slither/solc_parsing/solidity_types/type_parsing.py index d1c4e83cd..21b819e75 100644 --- a/slither/solc_parsing/solidity_types/type_parsing.py +++ b/slither/solc_parsing/solidity_types/type_parsing.py @@ -190,7 +190,12 @@ def _find_from_type_name( # pylint: disable=too-many-locals,too-many-branches,t return UserDefinedType(var_type) -def parse_type(t: Union[Dict, UnknownType], caller_context): +def parse_type( + t: Union[Dict, UnknownType], + caller_context: Union[ + "SlitherCompilationUnitSolc", "FunctionSolc", "ContractSolc", "CustomSolc" + ], +): # local import to avoid circular dependency # pylint: disable=too-many-locals,too-many-branches,too-many-statements # pylint: disable=import-outside-toplevel @@ -198,17 +203,22 @@ def parse_type(t: Union[Dict, UnknownType], caller_context): from slither.solc_parsing.variables.function_type_variable import FunctionTypeVariableSolc from slither.solc_parsing.declarations.contract import ContractSolc from slither.solc_parsing.declarations.function import FunctionSolc + from slither.solc_parsing.declarations.custom_error import CustomErrorSolc from slither.solc_parsing.slither_compilation_unit_solc import SlitherCompilationUnitSolc sl: "SlitherCompilationUnit" # Note: for convenicence top level functions use the same parser than function in contract # but contract_parser is set to None - if isinstance(caller_context, SlitherCompilationUnitSolc) or ( + if isinstance(caller_context, (SlitherCompilationUnitSolc, CustomErrorSolc)) or ( isinstance(caller_context, FunctionSolc) and caller_context.contract_parser is None ): + structures_direct_access: List["Structure"] if isinstance(caller_context, SlitherCompilationUnitSolc): sl = caller_context.compilation_unit next_context = caller_context + elif isinstance(caller_context, CustomErrorSolc): + sl = caller_context.underlying_custom_error.compilation_unit + next_context = caller_context.slither_parser else: assert isinstance(caller_context, FunctionSolc) sl = caller_context.underlying_function.compilation_unit @@ -235,13 +245,13 @@ def parse_type(t: Union[Dict, UnknownType], caller_context): contract = caller_context.underlying_contract next_context = caller_context - structures_direct_access = ( - contract.structures + contract.compilation_unit.structures_top_level - ) + structures_direct_access = contract.structures + structures_direct_access += contract.compilation_unit.structures_top_level all_structuress = [c.structures for c in contract.compilation_unit.contracts] all_structures = [item for sublist in all_structuress for item in sublist] all_structures += contract.compilation_unit.structures_top_level - enums_direct_access = contract.enums + contract.compilation_unit.enums_top_level + enums_direct_access: List["Enum"] = contract.enums + enums_direct_access += contract.compilation_unit.enums_top_level all_enumss = [c.enums for c in contract.compilation_unit.contracts] all_enums = [item for sublist in all_enumss for item in sublist] all_enums += contract.compilation_unit.enums_top_level diff --git a/tests/ast-parsing/compile/custom_error-0.4.0-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.0-legacy.zip new file mode 100644 index 000000000..45aa93540 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.0-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.1-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.1-legacy.zip new file mode 100644 index 000000000..4da0d8d93 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.1-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.10-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.10-legacy.zip new file mode 100644 index 000000000..db3215cb2 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.10-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.11-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.11-legacy.zip new file mode 100644 index 000000000..2718b2552 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.11-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.12-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.12-compact.zip new file mode 100644 index 000000000..2921a0588 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.12-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.12-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.12-legacy.zip new file mode 100644 index 000000000..95efd03df Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.12-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.13-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.13-compact.zip new file mode 100644 index 000000000..c0acaafca Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.13-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.13-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.13-legacy.zip new file mode 100644 index 000000000..61849e80e Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.13-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.14-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.14-compact.zip new file mode 100644 index 000000000..0b910af62 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.14-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.14-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.14-legacy.zip new file mode 100644 index 000000000..84e9aa286 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.14-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.15-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.15-compact.zip new file mode 100644 index 000000000..c3662208b Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.15-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.15-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.15-legacy.zip new file mode 100644 index 000000000..6966f4154 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.15-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.16-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.16-compact.zip new file mode 100644 index 000000000..7c7995bab Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.16-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.16-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.16-legacy.zip new file mode 100644 index 000000000..5427c26e9 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.16-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.17-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.17-compact.zip new file mode 100644 index 000000000..db9833f07 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.17-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.17-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.17-legacy.zip new file mode 100644 index 000000000..6cf97274b Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.17-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.18-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.18-compact.zip new file mode 100644 index 000000000..efc780ef6 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.18-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.18-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.18-legacy.zip new file mode 100644 index 000000000..bc6af6a43 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.18-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.19-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.19-compact.zip new file mode 100644 index 000000000..1174950a7 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.19-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.19-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.19-legacy.zip new file mode 100644 index 000000000..e75033abe Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.19-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.2-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.2-legacy.zip new file mode 100644 index 000000000..2541a7b92 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.2-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.20-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.20-compact.zip new file mode 100644 index 000000000..09b4aae6e Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.20-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.20-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.20-legacy.zip new file mode 100644 index 000000000..b3e04f680 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.20-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.21-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.21-compact.zip new file mode 100644 index 000000000..84f3633d3 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.21-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.21-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.21-legacy.zip new file mode 100644 index 000000000..62d823edd Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.21-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.22-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.22-compact.zip new file mode 100644 index 000000000..7cf966851 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.22-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.22-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.22-legacy.zip new file mode 100644 index 000000000..4224e17ec Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.22-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.23-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.23-compact.zip new file mode 100644 index 000000000..8238a4914 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.23-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.23-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.23-legacy.zip new file mode 100644 index 000000000..1b46a9bca Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.23-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.24-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.24-compact.zip new file mode 100644 index 000000000..3225144eb Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.24-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.24-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.24-legacy.zip new file mode 100644 index 000000000..b61f364ff Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.24-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.25-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.25-compact.zip new file mode 100644 index 000000000..5a44e6a4a Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.25-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.25-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.25-legacy.zip new file mode 100644 index 000000000..e05ce9631 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.25-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.26-compact.zip b/tests/ast-parsing/compile/custom_error-0.4.26-compact.zip new file mode 100644 index 000000000..7585ea209 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.26-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.26-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.26-legacy.zip new file mode 100644 index 000000000..4cfaa11d3 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.26-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.3-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.3-legacy.zip new file mode 100644 index 000000000..1b53b6cde Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.3-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.4-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.4-legacy.zip new file mode 100644 index 000000000..d3a039d69 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.4-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.5-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.5-legacy.zip new file mode 100644 index 000000000..7f57e57d7 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.5-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.6-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.6-legacy.zip new file mode 100644 index 000000000..079a8b892 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.6-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.7-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.7-legacy.zip new file mode 100644 index 000000000..a8d8e619e Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.7-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.8-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.8-legacy.zip new file mode 100644 index 000000000..0758d829c Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.8-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.4.9-legacy.zip b/tests/ast-parsing/compile/custom_error-0.4.9-legacy.zip new file mode 100644 index 000000000..347050544 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.4.9-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.0-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.0-compact.zip new file mode 100644 index 000000000..945b2c634 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.0-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.0-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.0-legacy.zip new file mode 100644 index 000000000..cd03e29f2 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.0-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.1-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.1-compact.zip new file mode 100644 index 000000000..c703c3bc9 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.1-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.1-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.1-legacy.zip new file mode 100644 index 000000000..dd7b72c6f Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.1-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.10-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.10-compact.zip new file mode 100644 index 000000000..89e01aa2b Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.10-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.10-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.10-legacy.zip new file mode 100644 index 000000000..fc0b4788c Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.10-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.11-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.11-compact.zip new file mode 100644 index 000000000..7d1b47d0a Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.11-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.11-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.11-legacy.zip new file mode 100644 index 000000000..9ba30100f Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.11-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.12-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.12-compact.zip new file mode 100644 index 000000000..cb7a5e0fb Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.12-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.12-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.12-legacy.zip new file mode 100644 index 000000000..df8446d3f Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.12-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.13-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.13-compact.zip new file mode 100644 index 000000000..0369574f6 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.13-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.13-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.13-legacy.zip new file mode 100644 index 000000000..899e8dada Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.13-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.14-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.14-compact.zip new file mode 100644 index 000000000..e0d3a2308 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.14-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.14-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.14-legacy.zip new file mode 100644 index 000000000..740a69097 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.14-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.15-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.15-compact.zip new file mode 100644 index 000000000..a9f64dc8a Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.15-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.15-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.15-legacy.zip new file mode 100644 index 000000000..ef59a0dad Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.15-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.16-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.16-compact.zip new file mode 100644 index 000000000..1b98ff888 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.16-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.16-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.16-legacy.zip new file mode 100644 index 000000000..349a7d972 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.16-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.17-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.17-compact.zip new file mode 100644 index 000000000..a862d5595 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.17-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.17-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.17-legacy.zip new file mode 100644 index 000000000..08cfcf969 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.17-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.2-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.2-compact.zip new file mode 100644 index 000000000..31009f2c5 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.2-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.2-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.2-legacy.zip new file mode 100644 index 000000000..6e66366a3 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.2-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.3-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.3-compact.zip new file mode 100644 index 000000000..11c17edd0 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.3-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.3-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.3-legacy.zip new file mode 100644 index 000000000..cc09e5a23 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.3-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.4-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.4-compact.zip new file mode 100644 index 000000000..e1d30fd68 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.4-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.4-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.4-legacy.zip new file mode 100644 index 000000000..44bba1e75 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.4-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.5-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.5-compact.zip new file mode 100644 index 000000000..3bc6ab3f2 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.5-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.5-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.5-legacy.zip new file mode 100644 index 000000000..e338b3d06 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.5-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.6-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.6-compact.zip new file mode 100644 index 000000000..71f935530 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.6-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.6-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.6-legacy.zip new file mode 100644 index 000000000..dcc7293f4 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.6-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.7-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.7-compact.zip new file mode 100644 index 000000000..2050d339e Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.7-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.7-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.7-legacy.zip new file mode 100644 index 000000000..8e2fdbafc Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.7-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.8-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.8-compact.zip new file mode 100644 index 000000000..7223c7567 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.8-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.8-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.8-legacy.zip new file mode 100644 index 000000000..c25d9e0e5 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.8-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.9-compact.zip b/tests/ast-parsing/compile/custom_error-0.5.9-compact.zip new file mode 100644 index 000000000..224a08eda Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.9-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.5.9-legacy.zip b/tests/ast-parsing/compile/custom_error-0.5.9-legacy.zip new file mode 100644 index 000000000..7203a0e3b Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.5.9-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.0-compact.zip b/tests/ast-parsing/compile/custom_error-0.6.0-compact.zip new file mode 100644 index 000000000..3b203a023 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.0-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.0-legacy.zip b/tests/ast-parsing/compile/custom_error-0.6.0-legacy.zip new file mode 100644 index 000000000..7e30e85e7 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.0-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.1-compact.zip b/tests/ast-parsing/compile/custom_error-0.6.1-compact.zip new file mode 100644 index 000000000..59465f3f3 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.1-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.1-legacy.zip b/tests/ast-parsing/compile/custom_error-0.6.1-legacy.zip new file mode 100644 index 000000000..cef2ef0b3 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.1-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.10-compact.zip b/tests/ast-parsing/compile/custom_error-0.6.10-compact.zip new file mode 100644 index 000000000..28f594b02 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.10-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.10-legacy.zip b/tests/ast-parsing/compile/custom_error-0.6.10-legacy.zip new file mode 100644 index 000000000..8bcdd0db1 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.10-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.11-compact.zip b/tests/ast-parsing/compile/custom_error-0.6.11-compact.zip new file mode 100644 index 000000000..3fb301733 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.11-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.11-legacy.zip b/tests/ast-parsing/compile/custom_error-0.6.11-legacy.zip new file mode 100644 index 000000000..cedd4590b Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.11-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.12-compact.zip b/tests/ast-parsing/compile/custom_error-0.6.12-compact.zip new file mode 100644 index 000000000..22d574f96 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.12-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.12-legacy.zip b/tests/ast-parsing/compile/custom_error-0.6.12-legacy.zip new file mode 100644 index 000000000..32a4a421c Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.12-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.2-compact.zip b/tests/ast-parsing/compile/custom_error-0.6.2-compact.zip new file mode 100644 index 000000000..8d721f3fd Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.2-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.2-legacy.zip b/tests/ast-parsing/compile/custom_error-0.6.2-legacy.zip new file mode 100644 index 000000000..896eea7d6 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.2-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.3-compact.zip b/tests/ast-parsing/compile/custom_error-0.6.3-compact.zip new file mode 100644 index 000000000..01dfeddd6 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.3-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.3-legacy.zip b/tests/ast-parsing/compile/custom_error-0.6.3-legacy.zip new file mode 100644 index 000000000..de300bdc0 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.3-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.4-compact.zip b/tests/ast-parsing/compile/custom_error-0.6.4-compact.zip new file mode 100644 index 000000000..b5c5b3d8f Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.4-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.4-legacy.zip b/tests/ast-parsing/compile/custom_error-0.6.4-legacy.zip new file mode 100644 index 000000000..a688083a2 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.4-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.5-compact.zip b/tests/ast-parsing/compile/custom_error-0.6.5-compact.zip new file mode 100644 index 000000000..09ef6758e Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.5-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.5-legacy.zip b/tests/ast-parsing/compile/custom_error-0.6.5-legacy.zip new file mode 100644 index 000000000..16b4829d9 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.5-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.6-compact.zip b/tests/ast-parsing/compile/custom_error-0.6.6-compact.zip new file mode 100644 index 000000000..d1cb13d83 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.6-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.6-legacy.zip b/tests/ast-parsing/compile/custom_error-0.6.6-legacy.zip new file mode 100644 index 000000000..08bdc27c7 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.6-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.7-compact.zip b/tests/ast-parsing/compile/custom_error-0.6.7-compact.zip new file mode 100644 index 000000000..c7e9bac1d Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.7-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.7-legacy.zip b/tests/ast-parsing/compile/custom_error-0.6.7-legacy.zip new file mode 100644 index 000000000..a89cb6479 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.7-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.8-compact.zip b/tests/ast-parsing/compile/custom_error-0.6.8-compact.zip new file mode 100644 index 000000000..99f0a0f9e Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.8-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.8-legacy.zip b/tests/ast-parsing/compile/custom_error-0.6.8-legacy.zip new file mode 100644 index 000000000..900668ce3 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.8-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.9-compact.zip b/tests/ast-parsing/compile/custom_error-0.6.9-compact.zip new file mode 100644 index 000000000..9e0f14ea2 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.9-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.6.9-legacy.zip b/tests/ast-parsing/compile/custom_error-0.6.9-legacy.zip new file mode 100644 index 000000000..da7c51b9f Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.6.9-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.0-compact.zip b/tests/ast-parsing/compile/custom_error-0.7.0-compact.zip new file mode 100644 index 000000000..6b6897139 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.0-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.0-legacy.zip b/tests/ast-parsing/compile/custom_error-0.7.0-legacy.zip new file mode 100644 index 000000000..d104ec84d Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.0-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.1-compact.zip b/tests/ast-parsing/compile/custom_error-0.7.1-compact.zip new file mode 100644 index 000000000..ae7674b6e Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.1-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.1-legacy.zip b/tests/ast-parsing/compile/custom_error-0.7.1-legacy.zip new file mode 100644 index 000000000..30dc23f89 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.1-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.2-compact.zip b/tests/ast-parsing/compile/custom_error-0.7.2-compact.zip new file mode 100644 index 000000000..b84522e6e Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.2-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.2-legacy.zip b/tests/ast-parsing/compile/custom_error-0.7.2-legacy.zip new file mode 100644 index 000000000..2bfe6d3b7 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.2-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.3-compact.zip b/tests/ast-parsing/compile/custom_error-0.7.3-compact.zip new file mode 100644 index 000000000..50ab663a9 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.3-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.3-legacy.zip b/tests/ast-parsing/compile/custom_error-0.7.3-legacy.zip new file mode 100644 index 000000000..3dc094047 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.3-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.4-compact.zip b/tests/ast-parsing/compile/custom_error-0.7.4-compact.zip new file mode 100644 index 000000000..30723f20d Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.4-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.4-legacy.zip b/tests/ast-parsing/compile/custom_error-0.7.4-legacy.zip new file mode 100644 index 000000000..0afddd3c2 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.4-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.5-compact.zip b/tests/ast-parsing/compile/custom_error-0.7.5-compact.zip new file mode 100644 index 000000000..9f637991d Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.5-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.5-legacy.zip b/tests/ast-parsing/compile/custom_error-0.7.5-legacy.zip new file mode 100644 index 000000000..70844b1b0 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.5-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.6-compact.zip b/tests/ast-parsing/compile/custom_error-0.7.6-compact.zip new file mode 100644 index 000000000..3ab1a8e7b Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.6-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.7.6-legacy.zip b/tests/ast-parsing/compile/custom_error-0.7.6-legacy.zip new file mode 100644 index 000000000..7135706c6 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.7.6-legacy.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.8.0-compact.zip b/tests/ast-parsing/compile/custom_error-0.8.0-compact.zip new file mode 100644 index 000000000..a0de75d88 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.8.0-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.8.1-compact.zip b/tests/ast-parsing/compile/custom_error-0.8.1-compact.zip new file mode 100644 index 000000000..c4eda7305 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.8.1-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.8.10-compact.zip b/tests/ast-parsing/compile/custom_error-0.8.10-compact.zip new file mode 100644 index 000000000..5fac2ba8d Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.8.10-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.8.2-compact.zip b/tests/ast-parsing/compile/custom_error-0.8.2-compact.zip new file mode 100644 index 000000000..f9d1a54ef Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.8.2-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.8.3-compact.zip b/tests/ast-parsing/compile/custom_error-0.8.3-compact.zip new file mode 100644 index 000000000..66cb969fd Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.8.3-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.8.4-compact.zip b/tests/ast-parsing/compile/custom_error-0.8.4-compact.zip new file mode 100644 index 000000000..e5e9a2935 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.8.4-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.8.5-compact.zip b/tests/ast-parsing/compile/custom_error-0.8.5-compact.zip new file mode 100644 index 000000000..a1e1cc166 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.8.5-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.8.6-compact.zip b/tests/ast-parsing/compile/custom_error-0.8.6-compact.zip new file mode 100644 index 000000000..c937beb6b Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.8.6-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.8.7-compact.zip b/tests/ast-parsing/compile/custom_error-0.8.7-compact.zip new file mode 100644 index 000000000..dcb8762b7 Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.8.7-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.8.8-compact.zip b/tests/ast-parsing/compile/custom_error-0.8.8-compact.zip new file mode 100644 index 000000000..fcc44253c Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.8.8-compact.zip differ diff --git a/tests/ast-parsing/compile/custom_error-0.8.9-compact.zip b/tests/ast-parsing/compile/custom_error-0.8.9-compact.zip new file mode 100644 index 000000000..4af11bb6b Binary files /dev/null and b/tests/ast-parsing/compile/custom_error-0.8.9-compact.zip differ diff --git a/tests/ast-parsing/custom_error-0.4.0.sol b/tests/ast-parsing/custom_error-0.4.0.sol new file mode 100644 index 000000000..a8dc8410f --- /dev/null +++ b/tests/ast-parsing/custom_error-0.4.0.sol @@ -0,0 +1 @@ +// not available util 0.8.4 diff --git a/tests/ast-parsing/custom_error-0.8.4.sol b/tests/ast-parsing/custom_error-0.8.4.sol new file mode 100644 index 000000000..8ddf97a98 --- /dev/null +++ b/tests/ast-parsing/custom_error-0.8.4.sol @@ -0,0 +1,41 @@ +pragma solidity ^0.8.4; + +struct St{ + uint v; +} + +error ErrorSimple(); +error ErrorWithArgs(uint, uint); +error ErrorWithStruct(St s); + +contract VendingMachine { + + function err0() public { + revert ErrorSimple(); + } + function err1() public { + St memory s; + revert ErrorWithStruct(s); + } + function err2() public{ + revert ErrorWithArgs(10+10, 10); + } + function err3() public{ + revert('test'); + } +} + +contract A{ + + error MyError(uint); + function f() public{ + revert MyError(2); + } +} + +contract B is A{ + function g() public{ + revert MyError(2); + } +} +