summaryrefslogtreecommitdiff
path: root/Test/test20/PolyProcs0.bpl
blob: cc0ba491cb62133cff4e2fd364ea83d62cf7f6af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// RUN: %boogie -noVerify "%s" > "%t"
// RUN: %diff "%s.expect" "%t"


type Field a;

function FieldAccessFun<b>(heap : <a>[ref, Field a]a, obj : ref, f : Field b)
         returns (res:b);

procedure FieldAccess<b>(heap : <a>[ref, Field a]a, obj : ref, f : Field b)
          returns (res:b) {
  start:
    res := heap[f, obj];    // error: wrong argument order
    res := heap[obj, f];
    assert res == FieldAccessFun(heap, obj, f);
    return;
}

procedure UseHeap(heap : <a>[ref, Field a]a) {
  var f1 : Field int; var f2 : Field bool; var obj : ref;
  var x : int; var y : bool;

  call x := FieldAccess(heap, f1, obj);  // error: wrong argument order
  call x := FieldAccess(heap, obj, f1);
  call y := FieldAccess(heap, obj, f2);

  call y := FieldAccess(heap, obj, f1);  // error: wrong result type
  call x := FieldAccess(heap, obj, obj); // error: wrong argument type
}

procedure injective<b>(heap : <a>[ref, Field a]a, obj0 : ref, obj1 : ref, f : Field b);
   requires obj0 != obj1;
   ensures heap[obj0, f] != heap[obj1, f];

type ref;