"private:" remains in effect after end of containing attribute{}

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Fri Apr 6 07:40:02 PDT 2007


Something I ran into today:
=====
$ cat test.d
import std.stdio;
import a;

void main()
{
     auto a = new A;
     writefln(a.b);
}
$ cat a.d
struct A {
     final {
         private:
         int a;
     }
     static bool b;
}
$ dmd test.d a.d
test.d(7): struct a.A member b is not accessible
=====
(After commenting out the "private:" line it compiles fine)

Is that error supposed to happen?
Shouldn't the one of the block endings stop the "private:" from 
remaining in effect afterwards?

The spec seems to be very clear on this. 
http://www.digitalmars.com/d/attribute.html says the "attribute:" syntax 
"affects all declarations until the next }".

(Note that I recently filed bug #1090 
(http://d.puremagic.com/issues/show_bug.cgi?id=1090) to change that 
sentence since as it stands now things like "version(Windows) { 
extern(Windows): }" should technically have no effect on anything, 
though the compiler doesn't implement it that way)

Since IMHO either that sentence or the compiler should be changed 
anyway, perhaps there should be some discussion about /which/ closing 
}'s should end the effects of an "attribute:" line.
Any thoughts?



More information about the Digitalmars-d mailing list