[Issue 5868] static attribute ignored with public static {} blocks

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 27 21:40:08 PST 2012


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


yebblies <yebblies at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies at gmail.com


--- Comment #12 from yebblies <yebblies at gmail.com> 2012-01-28 16:40:00 EST ---
(In reply to comment #11)

It's to do with the way the compiler handles attributes.  There are four kinds:

1. shared void func();
2. shared: void func();
3. shared { void func(); }
4. void func() shared;

The first two really evaluate to the third.  It doesn't make sense for the
third one to give an error on invalid attributes, as they might be intended to
a bunch of different declarations.  While the first one looks like is should be
rejected sometimes, to the compiler they're all the same.

The fourth case is special, in that the storage classes get passed directly to
the function declaration.  There is potential here for rejecting invalid
storage classes, but are there any that are actually invalid?

So to answer your question: Having attributes work this way make the parser
compiler simpler.  The decision most likely dates from a time when this was one
of D's major goals.

-- 
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