[Issue 6856] Preconditions are not inherited

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 1 10:07:49 PDT 2011


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



--- Comment #8 from Stewart Gordon <smjg at iname.com> 2011-11-01 10:06:36 PDT ---
(In reply to comment #2)
> Shouldn't "Y y" print "Y.f()" if Y can loose the in contract?
> Shouldn't "X z" and "Y z" print *something* (probably "X.f()" and "Y.f()"
> respectively)?

Only one of the contracts needs to pass for the overall contract to pass.  So
once it's tried one and found that it's passed, it doesn't need to try the
others.

When you have a Y, it first tries X's in contract.  This passes, so it doesn't
need to check Y's as well.  Of course, an implementation could just as well
check Y's contract first and then fall back to X's if that fails.

But because Z's in contract is empty, the compiler just optimises away the
whole contract checking.

-- 
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