Comment #0 by renezwanenburg — 2012-02-16T06:18:13Z
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.
Comment #1 by smjg — 2012-03-05T02:41:20Z
This is closely related to, if not a duplicate of, issue 6856.
Comment #2 by k.hara.pg — 2015-07-01T11:45:52Z
(In reply to Rene Zwanenburg from comment #0)
> enable's in contract is not being called.
Today this is intended behavior. See the discussion in issue 6856.
> After setting _enabled to true an
> exception is thrown saying C does not implement opCmp().
This is definitely wrong-code bug.
https://github.com/D-Programming-Language/dmd/pull/4794
Comment #3 by k.hara.pg — 2015-11-03T12:44:31Z
*** Issue 15274 has been marked as a duplicate of this issue. ***
Comment #4 by k.hara.pg — 2015-12-06T04:41:30Z
*** Issue 15346 has been marked as a duplicate of this issue. ***
Comment #5 by github-bugzilla — 2016-02-24T04:07:57Z