Stack too deep after importing interface
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
I got some unexpected behavior during compilation with solc 0.8.20. I can not tell if older versions had that problem too.
Timelock.sol contains the interface and 2 contracts if that is of any relevance...even if it should not.
Working code
```
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// Generates a stack to deep error
// import { ITimelock } from "../peripherals/Timelock.sol";
import { IVault } from "./Vault.sol";
import { IRouter } from "./Router.sol";
import { IShortsTracker } from "./ShortsTracker.sol";
interface ITimelock {
function marginFeeBasisPoints() external returns (uint256);
function setAdmin(address _admin) external;
function enableLeverage(address _vault) external;
function disableLeverage(address _vault) external;
function setIsLeverageEnabled(address _vault, bool _isLeverageEnabled) external;
function signalSetGov(address _target, address _gov) external;
}
library PositionUtils {
...
}
```
Code that throws Stack too deep error
```
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// Generates a stack to deep error
import { ITimelock } from "../peripherals/Timelock.sol";
import { IVault } from "./Vault.sol";
import { IRouter } from "./Router.sol";
import { IShortsTracker } from "./ShortsTracker.sol";
// interface ITimelock {
// function marginFeeBasisPoints() external returns (uint256);
// function setAdmin(address _admin) external;
// function enableLeverage(address _vault) external;
// function disableLeverage(address _vault) external;
// function setIsLeverageEnabled(address _vault, bool _isLeverageEnabled) external;
// function signalSetGov(address _target, address _gov) external;
// }
library PositionUtils {
...
}
```
Contributor guide
Research direction
Reproduce the reported compilation with solc 0.8.20 using the shown PositionUtils code, the local ITimelock interface, and the imported ../peripherals/Timelock.sol. Compare the two cases and inspect the referenced Vault.sol, Router.sol, and ShortsTracker.sol files; done means the import difference is explained and a confirmed compiler issue or required report details are identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- solidity
- Domain
- blockchain, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100