www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3979] New: Order-of-compilation and forward reference errors

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

           Summary: Order-of-compilation and forward reference errors
           Product: D
           Version: 2.041
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bugzilla kyllingen.net



01:39:39 PDT ---
I've run into this while working on std.process.  Take the following two files:

    // This is a.d:
    import std.stdio;

    // This is process.d:
    module std.process;
    import std.stdio;
    void foo(File f = std.stdio.stdin);

Compile them in the order they're written here, and you get a nonsensical
error:

    lars neutrino:~/tmp$ dmd -c a.d process.d
    process.d(3): Error: cannot implicitly convert expression (stdin)
    of type File to File

Make the following change to process.d:

    module std.process;
    import std.stdio: File, stdin;  // Selective imports now
    void foo(File f = std.stdio.stdin);

This causes an additional forward reference error:

    lars neutrino:~/tmp$ dmd -c a.d process.d
    process.d(2): Error: alias std.process.stdin forward reference of
    stdin
    process.d(3): Error: cannot implicitly convert expression (stdin)
    of type File to File

Compile them in reverse order, and it works fine in both cases:

    lars neutrino:~/tmp$ dmd -c process.d a.d


Note:  I'm marking this as a blocker because it's rather crucial to the new
std.process design, and I don't want to muck about with Andrei's makefile just
to make it compile.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 17 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3979


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au
           Severity|blocker                     |normal



This is a weird bug, but it seems to be caused by having a module with the same
name as one in the standard library. If you change the module statement to (for
example) module.std.process2; the problem disappears.
Since this is obscure (you probably won't encounter it unless you're working on
Phobos!) and has a trivial workaround, downgrading from blocker.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 09 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3979




00:18:56 PDT ---
I agree, the workaround is trivial up to the point where you want to include
the module in Phobos.  But that's exactly where I am now.

I can build Phobos with the module in question by changing the order of modules
in the makefile, but it's very fragile.  When I try to run the unittests, for
instance, the bug reappears.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 10 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3979


Lars T. Kyllingstad <bugzilla kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy yahoo.com



11:41:52 PDT ---
Anxious to get this extremely annoying problem fixed, I've finally been able to
reduce it to a small test case:

  // This is a.d
  module a;
  import b;
  struct Foo {}
  Foo foo;

  // This is b.d
  module b;
  import a;
  void fun(Foo f = a.foo);

Compilation gives:

  $ dmd -c a.d b.d
  b.d(4): Error: cannot implicitly convert expression (foo) of type Foo to Foo

Phew!  It took a while, hopefully it's worth it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 20 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3979


Rainer Schuetze <r.sagitario gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r.sagitario gmx.de



PDT ---
Now, it very much looks like bug 190 with the forward reference hidden in the
cyclic import.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 20 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3979


Adam D. Ruppe <destructionator gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator gmail.com



07:40:21 PDT ---
Has anyone tried Rainer's patch in bug 190 to see if it fixes this?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 16 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3979




PDT ---

 Has anyone tried Rainer's patch in bug 190 to see if it fixes this?
Yes, I did and it works for the reduced test case, too. Can't tell about the original report, though. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 16 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3979




00:46:28 PDT ---
It does indeed fix the original problem.  Thanks, Rainer!

Any chance we can get this into the next release?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 17 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3979


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



16:06:37 PDT ---
http://www.dsource.org/projects/dmd/changeset/634

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 27 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3979


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Depends on|                            |190, 4753
         Resolution|FIXED                       |



05:33:34 PDT ---
Reopened, Walter reverted the changes that fix this in
http://www.dsource.org/projects/dmd/changeset/652

It appears that 4753 has an updated patch, can be applied soon?

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


Lars T. Kyllingstad <bugzilla kyllingen.net> changed:

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



02:58:32 PST ---
Fixed again, along with bug 190.  Both the original and reduced test cases now
compile successfully.

http://www.dsource.org/projects/dmd/changeset/842

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