www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - D1: Error: function ... cannot have an in contract when overriden

reply "jicman" <jicman cinops.xerox.com> writes:
Greetings!

I am trying to compile dfl with the latest version of D1.  I am 
stuck in this error:

c:\D\import\dfl\button.d(381): Error: function 
dfl.button.Button.text cannot have
e an in contract when overriden function dfl.control.Control.text 
does not have an in contract

This is the line 381:

override void text(Dstring txt) // setter
in
{
	if(txt.length)
		assert(!this.image, "Button image with text not supported");
}
body
{
	super.text = txt;
}

alias Control.text text; // Overload.

Any help would be greatly appreciated.  Thanks.
Nov 07 2014
parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
If it is just that one error, you could always just comment out 
the in contract and recompile.
Nov 07 2014
parent reply "jicman" <jicman cinops.xerox.com> writes:
On Saturday, 8 November 2014 at 01:59:56 UTC, Adam D. Ruppe wrote:
 If it is just that one error, you could always just comment out 
 the in contract and recompile.
Sorry it took so long. Extremely busy, but anyway, this is the piece of the code that is causin the problem: <code> override void text(Dstring txt) // setter in { if(txt.length) assert(!this.image, "Button image with text not supported"); } body { super.text = txt; } alias Control.text text; // Overload. </code> I have no idea what these lines do. Any thoughts? Thanks. josé
Feb 15 2015
parent reply "Kagamin" <spam here.lot> writes:
It checks that you don't set both text and image, because the 
button doesn't support it.
Feb 15 2015
parent reply "jicman" <jicman cinops.xerox.com> writes:
On Monday, 16 February 2015 at 07:33:54 UTC, Kagamin wrote:
 It checks that you don't set both text and image, because the 
 button doesn't support it.
Yes, I get that. :-) I am talking about the in { } and also the body { } how are these interpreted by the compiler? They are both part of the function, correct?
Feb 16 2015
parent reply "Kagamin" <spam here.lot> writes:
http://digitalmars.com/d/1.0/dbc.html
in is precondition, body is function body, which expects 
precondition to pass.
Feb 16 2015
parent "jicman" <jicman cinops.xerox.com> writes:
On Monday, 16 February 2015 at 15:10:29 UTC, Kagamin wrote:
 http://digitalmars.com/d/1.0/dbc.html
 in is precondition, body is function body, which expects 
 precondition to pass.
Muchas gracias. (That is, "Thanks much", for the Spanish Speaking Challenged Community. :-))
Feb 16 2015