Bug 7517 – Interface contracts broken

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-16T06:18:00Z
Last change time
2016-05-02T13:37:13Z
Keywords
contracts, pull, wrong-code
Assigned to
nobody
Creator
renezwanenburg
Depends on
6856, 15984

Comments

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
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/5b7291428e22fd356df5e9540c093252152c854d fix Issue 7517 - Interface contracts broken https://github.com/D-Programming-Language/dmd/commit/65e058f5fdcc5c811f19c141eab25d67ed608925 Merge pull request #4794 from 9rnsr/fix7517 Issue 7517 - Interface contracts broken
Comment #6 by verylonglogin.reg — 2016-05-02T13:37:13Z
Please reopen if this is a cumulative issue as interface contracts are still broken, they can't access parameters (see Issue 15984).