Whiley/WyBench

Bug with 018_heap

Closed this issue · 0 comments

There is a bug in 018_heap which causes the following type invariant failure:

Check configuration has ints (-4..4), array lengths (max 4), type depths (max 1), sampling (0.001, limits 1000..10000000)  [0ms]
Checked type main::Heap (289/66429=0.0%, 4ms) ...................................... [47ms]
Failed function main::insert(Heap,int)->(Heap) (1000/2484=40.0%, 18ms) ............ [125ms]
================================================================================
./main.whiley:21: type invariant not satisfied
        heap.data[i] = heap.data[parent]
                       ^^^^^^^^^^^^^^^^^
Stack Trace:
--> main::insert({data: [2,0,-2,4],length: 3},4)

Hmmm, so this line looks suspicious:

        // perform a swap
        heap.data[i] = heap.data[parent]
        heap.data[i] = item

This aint no swap!