www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Static class members/methods and scope

reply Mike Parker <aldacron gmail.com> writes:
I'm certain this used to work:

class Foo
{
     public static
     {
         void bar() {}
     }
}

But I've found that now, anything inside the public static block is not 
actually static. I get an error attempting to call Foo.bar(). If I do this:

class Foo
{
     public
     {
         static void bar() {}
     }
}

...it works as expected. I tested with the override attribute, in case 
the handling of attributes had changed while I was away, but it works 
fine using the first form. I assume this is a bug, or a regression. Am I 
correct?
Apr 21 2011
parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Thu, 21 Apr 2011 04:54:49 -0400, Mike Parker <aldacron gmail.com> wrote:

 I'm certain this used to work:

 class Foo
 {
      public static
      {
          void bar() {}
      }
 }

 But I've found that now, anything inside the public static block is not  
 actually static. I get an error attempting to call Foo.bar(). If I do  
 this:

 class Foo
 {
      public
      {
          static void bar() {}
      }
 }

 ...it works as expected. I tested with the override attribute, in case  
 the handling of attributes had changed while I was away, but it works  
 fine using the first form. I assume this is a bug, or a regression. Am I  
 correct?
I would have expected the first form to work. You can file as a bug and see what happens. Worst case it gets closed as invalid :) -Steve
Apr 21 2011