crytic / crytic/slither

[Bug]: slither-flat generates out of order declarations

Open
#2,130 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
6.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

### Describe the issue:

The flattened output generated by slither-flat may declare contracts/interfaces out of order, which can't be compiled.

### Code example to reproduce the issue:

BSCscan address: https://bscscan.com/address/0x42d1aab8cbb202bc0b74c75da0fd999eec4a5c07#code

### Version:

0.9.6

### Relevant log output:

```shell
slither-flat output:

% slither-flat PEPEDEX.sol
INFO:Slither-flat:Export crytic-export/flattening/IFactoryV2_c9991fa7-b0b0-4e8f-8ba8-6532b8f1093a.sol
INFO:Slither-flat:Export crytic-export/flattening/IV2Pair_58e9d096-61c5-4602-9877-85cb33136549.sol
INFO:Slither-flat:Export crytic-export/flattening/IRouter02_10a3b720-0ff7-415a-9b25-259f5c5660c3.sol
INFO:Slither-flat:Export crytic-export/flattening/PEPEDEX_558f5239-3ddf-4e93-a5ac-d0979904c507.sol
```

Compile error:
```
% solc crytic-export/flattening/PEPEDEX_558f5239-3ddf-4e93-a5ac-d0979904c507.sol
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> crytic-export/flattening/PEPEDEX_558f5239-3ddf-4e93-a5ac-d0979904c507.sol

Error: Definition of base has to precede definition of derived contract
--> crytic-export/flattening/PEPEDEX_558f5239-3ddf-4e93-a5ac-d0979904c507.sol:2:24:
|
2 | interface IRouter02 is IRouter01 {
| ^^^^^^^^^
```

In the crytic-export/flattening/PEPEDEX_558f5239-3ddf-4e93-a5ac-d0979904c507.sol file, `IRouter01` is declared after `IRouter02`.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.