argotorg / argotorg/solidity

import names are not unified

Open
#15,569 0 comments 0 reactions 0 assignees View on GitHub
bug :bug:
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
21

Description

## Description

The `as` [import keyword](https://docs.soliditylang.org/en/latest/grammar.html#a4.SolidityParser.importDirective) used in `import "./file.sol" as name` creates names considered distinct from other imports of the same file under the same name.

They should be unified when they wrap the exact same file.

## Environment

solc 0.8.28

## Steps to Reproduce

```solidity
// imported.sol
contract C {}

// file1.sol
import "./imported.sol" as Imported;

// file2.sol
import "./imported.sol" as Imported;

// toplevel.sol
import "./file0.sol";
import "./file1.sol";

// Compilation fails with `Identifier already declared`.
```

Contrast the above with the 2 examples below, which both work:

```solidity
// imported.sol
contract C {}

// file1.sol
import {C} from "./imported.sol";

// file2.sol
import {C} from "./imported.sol";

// toplevel.sol
import "./file0.sol";
import "./file1.sol";

// Compilation succeeds.
```

and

```solidity
// imported.sol
contract C {}

// file1.sol
import {C as D} from "./imported.sol";

// file2.sol
import {C as D} from "./imported.sol";

// toplevel.sol
import "./file0.sol";
import "./file1.sol";

// Compilation succeeds.
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with solc 0.8.28 using imported.sol, file1.sol, file2.sol, and toplevel.sol from the report, then trace the compiler's import and name-resolution handling. Done means repeated `import "./imported.sol" as Imported` imports are unified when they refer to the exact same file, while the two working examples continue to compile.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.