Bug 6242 – Disallow inoperant "in" contracts

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-07-02T21:21:00Z
Last change time
2011-07-04T19:16:50Z
Keywords
accepts-invalid, patch
Assigned to
nobody
Creator
andrei

Comments

Comment #0 by andrei — 2011-07-02T21:21:52Z
Consider: class A { void fun(int) {} } class B : A { void fun(int x) in { assert(x > 0); } body {} } In this case B's in contract is never called. The compiler should disallow the code. To make the code work, an empty "in" contract on A.fun should suffice. The error message should mention that.
Comment #1 by yebblies — 2011-07-02T22:06:52Z
Comment #2 by bugzilla — 2011-07-03T12:05:35Z
Comment #3 by kennytm — 2011-07-04T11:21:03Z
Reopened as currently the code is still accepted. Perhaps pull 207 needs to be merged first. https://github.com/D-Programming-Language/dmd/pull/207
Comment #4 by bugzilla — 2011-07-04T19:16:50Z