Bug 9767 – Confusing compiler error generated when names collide across modules.
Status
RESOLVED
Resolution
DUPLICATE
Severity
trivial
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-20T11:10:00Z
Last change time
2013-03-20T14:30:53Z
Assigned to
nobody
Creator
andrew.smith
Comments
Comment #0 by andrew.smith — 2013-03-20T11:10:22Z
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.
Comment #1 by andrej.mitrovich — 2013-03-20T14:30:53Z
Basically the same thing as Issue 9631.
*** This issue has been marked as a duplicate of issue 9631 ***