www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7517] New: Interface contracts broken

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

           Summary: Interface contracts broken
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: renezwanenburg gmail.com



06:18:13 PST ---
interface I {

  void enable()
  in  { assert(!enabled); }
  out { assert( enabled); }

  void disable()
  in  { assert( enabled); }
  out { assert(!enabled); }

   property bool enabled() const;

}

class C : I {
  void enable() {
    _enabled = true;
  }

  void disable() {
    _enabled = false;
  }

   property bool enabled() const {
    return _enabled;
  }

  bool _enabled;
}

void foo() {
  I i = new C;
  i.enable();
}


enable's in contract is not being called. After setting _enabled to true an
exception is thrown saying C does not implement opCmp(). 

When removing the out contract from the interface, or the disable() function
from the interface and implementation (even though it's never being used
anywhere in the application), the code will run without exceptions but the
contracts will still not be called.

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


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
         Depends on|                            |6856



This is closely related to, if not a duplicate of, issue 6856.

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