www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9767] New: Confusing compiler error generated when names collide across modules.

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

           Summary: Confusing compiler error generated when names collide
                    across modules.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: trivial
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrew.smith uk.mlp.com



PDT ---
If I create two modules which contain duplicate declarations....

a.d
=====================
module a;
import b;

import std.stdio;

void function() voidFun;

struct foo {
  typeof( voidFun ) onCb;
};

void myCb() {
  writefln("I've been called");
};

void main() {
  foo f = { &myCb };
  usefoo(f);
};


and b.d
=========================
module b;

void function() voidFun;

struct foo {
  typeof(voidFun) onCb;
};


void usefoo( foo f) {
  f.onCb();
};

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

dmd produces following error message.

dmd -I. -c -ofa.o a.d
a.d(18): Error: function b.usefoo (foo f) is not callable using argument types
(foo)
a.d(18): Error: cannot implicitly convert expression (f) of type foo to foo
scons: *** [a.o] Error 1
scons: building terminated because of errors.


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

Obviously pilot error on my part but I'd argue the error message could be made
more helpful.

Cheers,

A.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 20 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9767


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |DUPLICATE



14:30:53 PDT ---
Basically the same thing as Issue 9631.

*** This issue has been marked as a duplicate of issue 9631 ***

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