D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3845 - [module system] A problem caused by duplicated import
Summary: [module system] A problem caused by duplicated import
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-23 17:48 UTC by bearophile_hugs
Modified: 2015-06-09 01:27 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-02-23 17:48:22 UTC
A small problem in the module system.
To see this problem you need 3 source files, named test1.d, mod1.d, mod2.d:

-----------------

module mod1;
import std.string: join;
import std.string: join;

-----------------

module mod2;
import std.string: join;

-----------------

The main module is test1.d:

module test1;
import mod1, mod2;
void main() {
    join(["a"], "");
}

-----------------

Got, DMD output:
test1.d(4): Error: mod1.join at mod1.d(2) conflicts with mod2.join at mod2.d(2)

Expected:
No errors, or an error in mod1 of duplicated import statement.

Note: in real code with many imports it's easy enough to import two times the same name from the same module.
Comment 1 bearophile_hugs 2010-08-01 15:10:51 UTC
See also bug 4563
Comment 2 Martin Nowak 2012-02-14 05:52:16 UTC
cat > mod1.d << CODE
module mod1;
import std.string: join;
import std.string: join;
CODE

cat > mod2.d << CODE
module mod2;
import std.string: join;
CODE

cat > test1.d << CODE
module test1;
import mod1, mod2;
void main() {
    join(["a"], "");
}
CODE

dmd -c test1.d

-------
mod1.d(2): Error: alias mod1.join conflicts with alias mod1.join at mod1.d(3)
                                                          ^--- mod1

It's complaining about:
import std.string: join;
import std.string: join;