[Issue 3254] Module member visibility depends on declaration order

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 20 06:27:27 PDT 2009


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





--- Comment #5 from Sergey Gromov <snake.scaly at gmail.com>  2009-08-20 06:27:26 PDT ---
> > From bug 314
> > > Access protection is defined to happen after lookup and
> > > overload resolution.
> Defined where in the spec?

That was Walter's comment.  This exact comment made me experiment with
module-level protection attributes and led to this bug report.

Well, I think the "overload before protection" rule has its merit for classes. 
Class methods *hide* methods of the same name in base classes to protect from
overload set hijacking.  It probably would be confusing if hiding rules worked
differently depending on whether your function is in the same module with the
class or not.

But module members cannot hide anything.  Any name collision is an error, and
any conflict resolution is explicit.  Therefore I think overload resolution
should be changed for modules, too.  Consider:

module a;
class A {}
void foo(A a) {}

module b;
class B {}
void foo(B b) {}

module c;
import a, b;
private alias a.foo foo;
private alias b.foo foo;
void bar() {
  foo(new A);
  foo(new B);
}

So far so good.  But now:

module d;
import a, c;
void baz() {
  foo(new A); // error ?!!
}

a.foo conflicts with c.foo ?  But I don't know about c.foo.  There is no
documentation for c.foo.  There is no c.foo.  Still, this phantom messes up
overloading.

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


More information about the Digitalmars-d-bugs mailing list