www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11065] New: Package-scoped import introduces symbol conflicts

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11065

           Summary: Package-scoped import introduces symbol conflicts
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-09-18
14:48:25 PDT ---
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).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 18 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11065



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-09-18
14:49:15 PDT ---
Also this test-case is Windows-specific due to the windows import from
druntime, I should have removed the dependency in the test-case..

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 18 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11065



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-09-18
14:50:51 PDT ---
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;
}
-----

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 18 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11065



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-09-18
15:03:20 PDT ---
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
----

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 18 2013