On 04/13/2012 02:41 AM, Joseph Rushton Wakeling wrote:
> On 13/04/12 01:44, bearophile wrote:
>> final size_t select(ref UniformRNG urng)
>> in {
>> assert(_recordsRemaining> 0);
>> assert(_sampleRemaining> 0);
>> } body {
>> ...
>> }
>
> OK. I'm confused by these asserts, because if I go beyond what is
> acceptable by calling select() even after I've collected a complete
> sample, no error is thrown.

This is a complicated issue that touches how in contracts are not inherited. I think your issue is because the interface does not define any in contracts, effectively allowing every call to select(). Please start reading here: :)

  http://d.puremagic.com/issues/show_bug.cgi?id=6856

As a general reminder, there is also the invariant() blocks, and sometimes enforce() is more appropriate than assert.

Ali


Reply via email to