blob: 0ceb46f11c0076f7288e17c3d195490af849c8a2 (
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
48
49
|
// RUN: %dafny "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
class C {
static function method Static() : bool
{
true
}
}
method K() {
var f := C.Static;
var o : object;
assert o !in f.reads();
assert f.requires();
assert f();
}
class T {
var h : int -> int;
}
function B(t : T) : int -> int
requires t != null;
reads t;
{
t.h
}
function J(t : T) : int
requires t != null
reads t
reads t.h.reads(0)
{
if t.h.requires(0) then
B(t)(0)
else
B(t)(0) // error: precondition violation
}
method U(t : T)
requires t != null;
modifies t;
{
t.h := x => x;
assert J(t) == 0; // ok
}
|