D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2402 - [module] Type is not found if accessed via renamed import
Summary: [module] Type is not found if accessed via renamed import
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2008-10-08 15:10 UTC by Koroskin Denis
Modified: 2015-06-09 01:20 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Koroskin Denis 2008-10-08 15:10:27 UTC
module m1;
struct Foo { int x; }

module m2;
struct Foo { int x; int y; }

module m;

import M1 = m1;
import M2 = x2;  // line 4
import M2 = m2;  // line 5

M2.Foo convert(M1.Foo foo)
{
    M2.Foo result = void;
    result.x = foo.x;
    result.y = foo.y;
    return result;
}

m.d(7): Error: identifier 'Foo' of 'M2.Foo' is not defined
m.d(7): Error: M2.Foo is used as a type

Note that swapping lines 4 and 5 workarounds the issue.

But there appears another issue:
m.d(11): Error: no property 'y' for type 'Foo'

Which one? Error should mention be M1.Foo instead of just Foo.
(Shall I move it into separate enhancement issue?)
Comment 1 Stewart Gordon 2008-11-24 10:35:33 UTC
The first thing it complains about should be that x2 is not found.  Or if it is, that M2 is defined twice.

I agree about your last comment.  It should probably be (and might already be, but I'm not sure) filed as a separate issue.
Comment 2 Martin Nowak 2012-02-14 05:35:41 UTC
cat > m1.d << CODE
module m1;
struct Foo { int x; }
CODE

cat > m2.d << CODE
module m2;
struct Foo { int x; int y; }
CODE

cat > m.d << CODE
module m;

import M1 = m1;
import M2 = x2;  // line 4
import M2 = m2;  // line 5

M2.Foo convert(M1.Foo foo)
{
    M2.Foo result = void;
    result.x = foo.x;
    result.y = foo.y;
    return result;
}
CODE

dmd -c m.d

----------

With dmd2.057:
m.d(4): Error: module x2 is in file 'x2.d' which cannot be read