Bug 4562 – D2 Language Docs: http://www.digitalmars.com/d/2.0/dbc.html

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-08-01T14:58:00Z
Last change time
2012-01-04T07:45:24Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2010-08-01T14:58:13Z
It states: "A function without an in contract means that any values of the function parameters are allowed. This implies that if any function in an inheritance hierarchy has no in contract, then in contracts on functions overriding it have no useful effect." But my example proves otherwise: class A { int test(int x) { return x * 2; } } class B : A { int test(int x) in { assert(x == 20); } body { return x * 2; } } void main() { B b = new B; b.test(10); } This will raise an assert error, which would negate the statement "in contracts on functions overriding it have no useful effect.".
Comment #1 by andrej.mitrovich — 2012-01-04T07:45:24Z
This has turned into a CT error in 2.057 and probably earlier: test.d(11): Error: function test.B.test cannot have an in contract when overriden function test.A.test does not have an in contract I think it's ok to close it then.