Thread overview
[Issue 900] New: changing import order causes type mismatch
Jan 28, 2007
d-bugmail
Jan 29, 2007
d-bugmail
Jan 29, 2007
d-bugmail
Jan 29, 2007
d-bugmail
Apr 03, 2007
d-bugmail
Nov 13, 2009
Leandro Lucarella
Mar 29, 2010
Jesse Phillips
Apr 15, 2010
Jesse Phillips
Feb 14, 2012
dawg@dawgfoto.de
Feb 14, 2012
dawg@dawgfoto.de
January 28, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=900

           Summary: changing import order causes type mismatch
           Product: D
           Version: 1.004
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: torhu@yahoo.com


Tested with DMD 1.0 and 1.004 on winxp.

There are 4 files involved:

// palette.d
module palette;

struct RGB { }

=========================================
// color_inl.d
module color_inl;

//uncommenting this line will fix the problem
//import palette : RGB:

import color;

void _set_color(RGB* p) { }

=========================================
// color.d
module color;

// swapping the order of these two lines will also fix the problem
public import color_inl;
import palette : RGB;

=========================================
// dtest.d
import color;

void fade()
{
   RGB rgb;
   _set_color(&rgb);
}

void main() {}

========================================

C:\prog\test\D\bugtest>dmd test.d
test.d(6): function color_inl._set_color (int,RGB*) does not match parameter
types (int,RGB *)
test.d(6): Error: cannot implicitly convert expression (& rgb) of type RGB * to
RGB*


-- 

January 29, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=900


torhu@yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|rejects-valid               |




------- Comment #1 from torhu@yahoo.com  2007-01-29 02:34 -------
Are selective imports private by default or not?  The docs state that imports are public by default, but also says that selective imports are "bound into the current namespace".

I take it they are supposed to be private, which means this bug is really about the compiler accepting invalid code, since color_inl.d and dtest.d are able to use RGB without importing palette.d.


-- 

January 29, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=900





------- Comment #2 from larsivar@igesund.net  2007-01-29 03:59 -------
Imports are private by default, if the spec says anything else, create a bug report for it.


-- 

January 29, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=900





------- Comment #3 from torhu@yahoo.com  2007-01-29 17:42 -------
(In reply to comment #2)
The problem is that I don't know if "bound into the current namespace" implies
that it's also automatically exported as part of the importing module.

Probably it shouldn't imply that, since the point of selective imports seems to be to avoid name conflicts in the importing module.

But this still confuses me, so I think there should be a clarification in the docs.  At least so we know what is correct when the compiler is somewhere in between.


-- 

April 03, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=900





------- Comment #4 from torhu@yahoo.com  2007-04-03 13:00 -------
(In reply to comment #2)
 A couple of bug reports here that suggest that selective, static, and renamed
imports are meant to be be private.

http://d.puremagic.com/issues/show_bug.cgi?id=604 http://d.puremagic.com/issues/show_bug.cgi?id=314

The question remains whether this is intended, or not.  In DMD, they are currently public.  Were they supposed to be private?  The docs don't say.


-- 

November 13, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=900


Leandro Lucarella <llucax@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |llucax@gmail.com


--- Comment #5 from Leandro Lucarella <llucax@gmail.com> 2009-11-13 15:50:57 PST ---
I think the spec is quite clear:

  [...]
  Public Imports

  By default, imports are private. [...]

http://www.digitalmars.com/d/1.0/module.html#ImportDeclaration

Static, renamed and selective import are all *import*, so it looks like they all should be private by default (for the same reason basic imports are).

This bug is old and doesn't look very useful, I think it should be closed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 29, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=900


Jesse Phillips <Jesse.K.Phillips+D@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Jesse.K.Phillips+D@gmail.co
                   |                            |m


--- Comment #6 from Jesse Phillips <Jesse.K.Phillips+D@gmail.com> 2010-03-29 16:42:17 PDT ---
I seem to have run across this in DMD 2.042. Here a static assert fails with the error:

=====================
C:\opt\dmd\windows\bin\..\..\src\phobos\std\typecons.d(424): Error: static
assert  (is(Tuple!(string,float) == Tuple!(string,float))) is false

C:\opt\dmd\windows\bin\..\..\src\phobos\std\typecons.d(413): instantiated from here: Tuple!(string,float)

C:\opt\dmd\windows\bin\..\..\src\phobos\std\typecons.d(423): instantiated from here: slice!(1,3)

C:\opt\dmd\windows\bin\..\..\src\phobos\std\typecons.d(420):
instantiated from here: Tuple!(int,string,float,double)

C:\opt\dmd\windows\bin\..\..\src\phobos\std\regex.d(260):
instantiated from here: Tuple!(string,string)

C:\opt\dmd\windows\bin\..\..\src\phobos\std\regex.d(280):
instantiated from here: opCall!(string)

C:\opt\dmd\windows\bin\..\..\src\phobos\std\regex.d(1519):
instantiated from here: Regex!(char).\test2.d(7):
instantiated from here: regex!(string)
===================

--------------------------
// Place string after import test2 to make this work
import std.string;
import test2;

void main() {
    new TestMe();
}
------------------------------

--------------------
module test2;

import std.regex;

class TestMe {
    void test(string input) {
        auto foo = !match(input, regex("fish")).empty;
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 15, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=900



--- Comment #7 from Jesse Phillips <Jesse.K.Phillips+D@gmail.com> 2010-04-15 14:23:31 PDT ---
My import issue is no longer in DMD 2.043, but the original submission's code still doesn't work.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 14, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=900


dawg@dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dawg@dawgfoto.de
         Resolution|                            |INVALID


--- Comment #8 from dawg@dawgfoto.de 2012-02-14 05:03:30 PST ---
This is invalid because 'import palette : RGB;' introduces RGB as private
alias.
You cannot access it from color_inl.
Changing that to 'public import palette : RGB' will fix your problem.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 14, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=900


dawg@dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


--- Comment #9 from dawg@dawgfoto.de 2012-02-14 05:29:54 PST ---
Sorry, I was using a wrong dmd version.
Changing it to 'public import palette : RGB' will fail because
of a forward reference error. This happens due to the cyclic import of color
and color_inc.

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