www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7441] New: interface allowes empty statics and replace of statics

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

           Summary: interface allowes empty statics and replace of statics
           Product: D
           Version: D2
          Platform: All
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dl.soluz gmx.net



---
import std.stdio;

interface itest
{
  static void implemented_static()
  {
    writeln("static itest.implemented_static");
  } // ok

  static void empty_static(); // missing implementation
}

class A: itest
{
  // silently replaces the interface implementation - no warning/error?
  static void implemented_static()
  {
    writeln("static A.implemented_static");
  };

  // implements the empty static - error?
  static void empty_static()
  {
    writeln("static A.empty_static");
  };
}

class B: itest
{
  // static becomes silently an method - no warning/error?
  void implemented_static()
  {
    writeln("(method) B.implemented_static");
  }

  // static becomes silently an method - no warning/error?
  void empty_static()
  {
    writeln("(method) B.empty_static");
  }
}

int main()
{
  itest.implemented_static();
  //itest.empty_static(); // error

  A.implemented_static();
  A.empty_static();

  itest a = new A();
  a.implemented_static();
  //a.empty_static(); // error

  B b = new B();
  b.implemented_static();
  b.empty_static();

  return 0;
}

Tested with dmd2.0.57/Win32

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 05 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7441


yebblies <yebblies gmail.com> changed:

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



None of these things are bugs.

Methods are allowed to have no body, the body can be provided in a different
source/object file and this is resolved at link time.

It is not illegal to shadow the name of a static function in a base
class/interface.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 05 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7441




Yes.  You can always open an enhancement request, but as C++ supports both
these things it's unlikely they will change.  (There may already be an
enhancement request for the second point)

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