diff options
author | leino <unknown> | 2014-12-12 20:46:48 -0800 |
---|---|---|
committer | leino <unknown> | 2014-12-12 20:46:48 -0800 |
commit | 91c4d57eb84d5d15e011902a1da1b70131e5a222 (patch) | |
tree | 6794bafdc71f6bc31c8d09496c3435658bbfc144 /Test/dafny0/Refinement.dfy | |
parent | 62a3e97eb61cbee0d523297ccad1f2d3bcf871c3 (diff) |
Language change: All functions and methods declared lexically outside any class are now
automatically static, and fields are no longer allowed to be declared there. Stated
differently, all heap state must now be declared inside an explicitly declared class,
and functions and methods declared outside any class can be viewed as belonging to
the module. The motivating benefit of this change is to no longer need the 'static'
keyword when declaring a module of functions and methods.
Diffstat (limited to 'Test/dafny0/Refinement.dfy')
-rw-r--r-- | Test/dafny0/Refinement.dfy | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/Test/dafny0/Refinement.dfy b/Test/dafny0/Refinement.dfy index 1a9a3257..a92e647a 100644 --- a/Test/dafny0/Refinement.dfy +++ b/Test/dafny0/Refinement.dfy @@ -38,30 +38,36 @@ module B refines A { // ------------------------------------------------ module A_AnonymousClass { - var x: int; - method Increment(d: int) - modifies this; - { - x := x + d; + class XX { + var x: int; + method Increment(d: int) + modifies this; + { + x := x + d; + } } } module B_AnonymousClass refines A_AnonymousClass { - method Increment... - ensures x <= old(x) + d; + class XX { + method Increment... + ensures x <= old(x) + d; + } } module C_AnonymousClass refines B_AnonymousClass { - method Increment(d: int) - ensures old(x) + d <= x; - method Main() - modifies this; - { - x := 25; - Increment(30); - assert x == 55; - Increment(12); - assert x == 66; // error: it's 67 + class XX { + method Increment(d: int) + ensures old(x) + d <= x; + method Main() + modifies this; + { + x := 25; + Increment(30); + assert x == 55; + Increment(12); + assert x == 66; // error: it's 67 + } } } |