www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - abstract class member functions can not have contracts

reply "ref2401" <refactor24 gmail.com> writes:
Interface member functions can have in/out contracts but why 
abstract class member functions can not?

abstract class Base
{
	 property int field();

	void foo() in { assert(field > 0); }	
// Error: function main.Base.foo in and out contracts require 
function body
// An empty body definition fixes this error.

}

interface IBase
{
	 property int field();

	void foo() in { assert(field > 0); } // OK
}
May 15 2013
parent Timon Gehr <timon.gehr gmx.ch> writes:
On 05/15/2013 04:16 PM, ref2401 wrote:
 Interface member functions can have in/out contracts but why abstract
 class member functions can not?

 abstract class Base
 {
       property int field();

      void foo() in { assert(field > 0); }
 // Error: function main.Base.foo in and out contracts require function body
 // An empty body definition fixes this error.

 }

 interface IBase
 {
       property int field();

      void foo() in { assert(field > 0); } // OK
 }
No reason. http://d.puremagic.com/issues/show_bug.cgi?id=6549
May 15 2013