Why do 'abstract' methods with 'in' or 'out' contracts require a body?

Trey Brisbane via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Sep 12 22:07:30 PDT 2014


Hey all,

I have a class method defined like so:

abstract class MyClass {
public:
	@property
	abstract SomeClassType getField() pure nothrow
	out(result) {
		assert(result !is null, "Error: getField() returned null.");
	}
}

As you can see, this method is abstract, as well as in an 
abstract class. Why, then, do I get the following error when 
compiling it?

"Error: function module.MyClass.getField in and out contracts 
require function body"

Is this a compiler bug, or is there a reason for this?

Thanks for your time!


More information about the Digitalmars-d-learn mailing list