argotorg / argotorg/solidity

Spurious shadowing warnings for later declarations in scopes where shadowing is order-dependent

Open
#16,190 4 comments 0 reactions 0 assignees View on GitHub
bug :bug: low effort medium impact must have
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.