out contract misunderstanding (was: I cannot understand problem with argument of the function)

mrd denis.feklushkin at gmail.com
Wed Sep 18 18:41:13 PDT 2013


(new topic because old is mired in a long and clumsy source code)

============
import std.stdio;

static ubyte func( ulong value )
out( arr )
{
     writeln( "out contract, value=", value );
}
body
{
     writeln( "body, value=", value );
     ubyte res;
     value >>= 7;
     return res;
}

void main()
{
     func( 2 );
}
============

$ ./bug
body, value=2
out contract, value=0

Why argument "value" in contract isn't equal 2 ?


More information about the Digitalmars-d-learn mailing list