From 9db6f4396eefc467de0470547767c1639d642945 Mon Sep 17 00:00:00 2001 From: Josselin Date: Thu, 3 Oct 2019 08:40:31 +0200 Subject: [PATCH] Fix incorrect flattening --- slither/tools/flattening/flattening.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/slither/tools/flattening/flattening.py b/slither/tools/flattening/flattening.py index 6acd8200a..ccf398009 100644 --- a/slither/tools/flattening/flattening.py +++ b/slither/tools/flattening/flattening.py @@ -121,7 +121,8 @@ class Flattening: self._export_contract(ir.contract_created, exported, list_contract) if isinstance(ir, TypeConversion): self._export_from_type(ir.type, contract, exported, list_contract) - + if contract.name in exported: + return exported.add(contract.name) list_contract.append(self._source_codes[contract]) @@ -142,14 +143,15 @@ class Flattening: if not self.DEFAULT_EXPORT_PATH.exists(): self.DEFAULT_EXPORT_PATH.mkdir(parents=True) - ret = [] if target is None: for contract in self._slither.contracts_derived: + ret = [] self._export(contract, ret) else: contract = self._slither.get_contract_from_name(target) if contract is None: logger.error(f'{target} not found') else: + ret = [] self._export(contract, ret)