summaryrefslogtreecommitdiff
path: root/Test/test1/WhereTyping.bpl
blob: b3675f45ea6e542cdc315de3b6f25c293e3f4ba3 (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
36
37
38
39
40
41
42
43
44
45
46
47
// RUN: %boogie -noVerify "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
var g: int where g == 12;

procedure P(x: int where x > 0) returns (y: int where y < 0);
  requires x < 100;
  modifies g;
  ensures -100 < y;

implementation P(xx: int) returns (yy: int)
{
  var a: int;
  var b: int;

  start:
    a := xx;
    call b := P(a);
    yy := b;
    return;
}

type double;
function F(double) returns (double);
function G(double) returns (bool);

procedure Q(omega: double where omega == F(omega),
            psi: double where psi + 1 == 0,  // error: psi doesn't have right type for +
            pi: double where F(pi),          // error: F has wrong return type
            sigma: double where G(sigma));


const SomeConstant: name;
function fgh(int) returns (int);

procedure Cnst(n: name where n <: SomeConstant /*this SomeConstant refers to the const*/) returns (SomeConstant: int)
{
  var k: int where k != SomeConstant;  // fine, since SomeConstants refers to the out parameter
  var m: name where m != SomeConstant;  // error: types don't match up
  var r: ref where (forall abc: int :: abc == SomeConstant);
  var b: bool;
  start:
    b := (forall x: int :: fgh(x) < SomeConstant);
    b := (forall l: name :: l == SomeConstant);  // error: SomeConstant here refers to the out parameter
    return;
}

type ref, name;