www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17930] New: [Contract Programming] 23.3 In, Out and Inheritance


          Issue ID: 17930
           Summary: [Contract Programming] 23.3 In, Out and Inheritance
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: dlang.org
          Assignee: nobody puremagic.com
          Reporter: resmith5 outlook.com

The section says 

"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 it appears that a compile error is generated when an overridden function
has an "in" and the function it is overriding does not, rather than the
contract having no effect - a compile error is encountered:

contracts.d(34): Error: function contracts.TestContractsDerived.someFunction
cannot have an in contract when overridden function
contracts.TestContractsBase.someFunction does not have an in contract
makefile:77: recipe for target 'contracts' failed

Oct 22 2017