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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 2 13:13:10 PDT 2012


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


timon.gehr at gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |
           Severity|normal                      |enhancement


--- Comment #6 from timon.gehr at gmx.ch 2012-05-02 13:14:21 PDT ---
(In reply to comment #5)
> This report is invalid,

I disagree.

> it is working as designed.
> 

Therefore the design is flawed and this report is an enhancement.

> This is how inheritance of contracts and overriding of functions is supposed to
> work.
> 

This report is not about how inheritance and overriding work, it is about
static vs. dynamic binding. (Though inheritance and overriding of contracts
also don't work how they are supposed to work, see issues 6856 and 7584.)

> >void fun(A a)
> >The point is that fun() must satisfy the precondition for A.
> 
> This is incorrect. It must satisfy the precondition for A or any class derived
> from A.

How does it know which one to satisfy? If it does, it might as well just
downcast the reference in order to get a wider interface. If it does not, it is
a bug in fun() if it fails to satisfy the precondition for A. (It's signature
claims it can handle all A's!)

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