argotorg / argotorg/solidity

Error: `Definition of base has to precede definition of derived contract` when specific file in standard-json-input `outputSelection` but works when `outputSelection` file is specific

Open
#12,932 6 comments 0 reactions 1 assignee Assigned to @cameel View on GitHub
bug :bug: high impact low effort must have should compile without error
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
21

Description

## Description

When compiling with the specific file in the standard-json-input's `outputSelection` field, the compiler throws the error `Definition of base has to precede definition of derived contract` but when the files in the `outputSelection` is given as `"*"` the compiler compiles successfully.

Noticed this as the [Sourcify](https://github.com/ethereum/sourcify) recompiler targets the specific file and output in the generated json-input and couldn't compile but the user was able to compile and deploy the contract via Hardhat (which has `"*"` in `outputSelection`.)

I'd say the error is correct since according to the order of importing the definition of the base contract is below the inheriting contract, as suggested by the error. Nevertheless a change in the `outputSelection` should not be effecting how the compiler behaves.

this `outputSelection` throws:
```json
"settings": {
"evmVersion": "london",
"libraries": { "": {} },
"metadata": { "bytecodeHash": "ipfs" },
"optimizer": { "enabled": true, "runs": 200 },
"remappings": [],
"outputSelection": {
"contracts/teleporteth/contracts/TeleportTokenFactory.sol": {
"TeleportTokenFactory": [
"evm.bytecode.object",
"evm.deployedBytecode.object",
"metadata"
]
}
}
}
```
while this compiles:
```json
"settings": {
"evmVersion": "london",
"libraries": { "": {} },
"metadata": { "bytecodeHash": "ipfs" },
"optimizer": { "enabled": true, "runs": 200 },
"remappings": [],
"outputSelection": {
"*": { // <-- diff
"TeleportTokenFactory": [
"evm.bytecode.object",
"evm.deployedBytecode.object",
"metadata"
]
}
}
}
```

## Environment

- Compiler version: 0.8.7 (originally), also tried 0.8.13
- Target EVM version (as per compiler settings): london
- Framework/IDE (e.g. Truffle or Remix): solc
- EVM execution environment / backend / blockchain client:
- Operating system: Ubuntu 20.04

## Steps to Reproduce
I am adding the full standard-json-input files with just the diff in the `outputSelection`. Also adding the `.sol` files for reference.
[compiles-with-asterisk.json.txt](https://github.com/ethereum/solidity/files/8481863/compiles-with-asterisk.json.txt)
[error-specific-file.json.txt](https://github.com/ethereum/solidity/files/8481865/error-specific-file.json.txt)
[TeleportToken.sol.txt](https://github.com/ethereum/solidity/files/8481879/TeleportToken.sol.txt)
[TeleportTokenFactory.sol.txt](https://github.com/ethereum/solidity/files/8481880/TeleportTokenFactory.sol.txt)

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.