[Issue 6857] Precondition contract checks should be statically bound.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 4 13:40:36 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=6857



--- Comment #35 from Walter Bright <bugzilla at digitalmars.com> 2012-05-04 13:41:50 PDT ---
(In reply to comment #34)
> But you could still argue that the call is in breach of A's API and therefore
> the code is incorrect.

Again, this is NOT true. The type of the argument is not statically A, it is a
polymorphic type A.

If an instance of A is passed, then the call to foo(-1) will fail. Please try
it and see for yourself. There is no hole in the system.


> To be correct, the in contract for A.foo would have to
> be something like
> 
> in { assert(x > 0 || x == bar()); }
> 
> But since enforcing this now is a potentially breaking change, I can now see a
> case for leaving the behvaiour as it is.

You are still seeing this as a bug in the OOP design. It is not. The design is
sound and correct.

If you still disagree, please write a code sample that asserts when it should
not, or passes when it must not, compile it and run it, and post it here.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list