blob: 7f1c2948b83e0ece5526a3da067386cf4a83c74a (
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
|
class N
{
var i: int;
method newN(n: N)
requires n != null;
modifies this, n;
{
n.i := 1;
i := 1;
}
method safe(n: N)
requires n != null;
modifies this;
{
i := n.i;
}
}
method m(v: int, n: N) returns (r: int)
modifies n;
ensures r == v;
{
r := v;
}
method testing1() returns (s: int)
ensures s == 3;
{
var n := new N;
return m(3, n); // ERROR: methods disallowed.
}
method testing2() returns (s: int, b: int)
ensures s == 3;
{
var n := new N;
return m(3, n), 2; // ERROR: methods disallowed.
}
method testing3() returns (n: N)
{
return new N.newN(n); // ERROR: disallowed, as newN() modifies n
}
|