Summary: Interface contracts broken
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD

--- Comment #0 from Rene Zwanenburg <> 2012-02-16 
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;

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:
------- You are receiving this mail because: -------

Reply via email to