Spurious shadowing warnings for later declarations in scopes where shadowing is order-dependent
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
## Description
I get shadow declaration warnings for variable definitions that are defined in separate scopes. That cannot possible refer to each other.
## Environment
- Compiler version: 0.8.29
- Compilation pipeline (legacy, IR, EOF): legacy
- Target EVM version (as per compiler settings): cancun
- Framework/IDE (e.g. Foundry, Hardhat, Remix): foundryj
- Operating system: MacOS
## Steps to Reproduce
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Bob {
function myFunc() external view returns (uint256) {
{
uint256 x = 34;
x -= address(this).balance;
}
uint256 x = 33 + 2;
return x;
}
}
```
Contributor guide
Research direction
Compile the provided Solidity reproducer with compiler version 0.8.29 using the legacy pipeline and inspect the shadowing warnings for the two separately scoped declarations. Trace the warning source from that compiler entry point and add a regression test showing that the later declaration does not produce a spurious warning when the scopes are order-dependent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- solidity
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100