www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3329] New: Static constructors not allowed in interfaces

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3329

           Summary: Static constructors not allowed in interfaces
           Product: D
           Version: 1.046
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dhasenan gmail.com



---
Interfaces can have const fields, which are implicitly static. They can have
static fields that are not const.

Let's take this example (from ANTLR):
interface Token
{
   const int EOF = -1;
   static Token EOF_TOKEN;
   static this ()
   {
      EOF_TOKEN = new CommonToken(EOF);
   }
}

This produces an error saying that _staticCtor1 is not abstract.

The workaround is to move the static constructor out of the interface. This is
not problematic; it is merely inconsistent.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 18 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3329


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |FIXED



This compiles successfully: static constructors are now allowed in interfaces
(dmd1.068 & dmd2.053)

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