D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11065 - Package-scoped import introduces symbol conflicts
Summary: Package-scoped import introduces symbol conflicts
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-18 14:48 UTC by Andrej Mitrovic
Modified: 2024-12-13 18:11 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2013-09-18 14:48:25 UTC
test.d:

-----
module test;

import foo;
import bar;

void main()
{
    auto x = RGB(0, 0, 255);
}
-----

foo.d:
-----
module foo;

struct RGB
{
    ubyte r;
    ubyte g;
    ubyte b;
}
-----

bar.d:
-----
module bar;

package:

import core.sys.windows.windows;
-----

$ dmd -c test.d
test.d(8): Error: foo.RGB at foo.d(4) conflicts with core.sys.windows.win
dows.RGB at C:\dmd-git\dmd2\windows\bin\..\..\src\druntime\import\core\sy
s\windows\windows.d(3213)

If you remove the "package:" specifier, the error is gone. It's also unrelated to whether these modules are actually part of any package structure (the test-case is kept simple here).

This does not appear to be a regression (tested up to 2.060).
Comment 1 Andrej Mitrovic 2013-09-18 14:49:15 UTC
Also this test-case is Windows-specific due to the windows import from druntime, I should have removed the dependency in the test-case..
Comment 2 Andrej Mitrovic 2013-09-18 14:50:51 UTC
Here's the new test-case without the win32 dependency:

test.d:
-----
module test;

import foo;
import bar;

void main()
{
    auto x = RGB(0, 0, 255);
}
-----

foo.d:
-----
module foo;

struct RGB
{
    ubyte r, g, b;
}
-----

bar.d:
-----
module bar;

package:

import doo;
-----

doo.d:
-----
struct RGB
{
    ubyte r, g, b;
}
-----
Comment 3 Andrej Mitrovic 2013-09-18 15:03:20 UTC
The problem of course is that "package" has no real meaning for imports, and should therefore be ignored. In other words, this:

----
package:

import abcd;
----

Should not mark the import as a package import (this has no meaning in the spec), it should stay as a private import unless typed differently, e.g.:

----
package:

import abcd;  // private import

void foo() { }  // package function
----
Comment 4 dlangBugzillaToGithub 2024-12-13 18:11:38 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18673

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB