Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import names are not unified #15569

Open
adhusson opened this issue Nov 6, 2024 · 0 comments
Open

import names are not unified #15569

adhusson opened this issue Nov 6, 2024 · 0 comments
Labels

Comments

@adhusson
Copy link

adhusson commented Nov 6, 2024

Description

The as import keyword 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

// 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:

// 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

// 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant