summaryrefslogtreecommitdiff
path: root/Test/dafny0/CoResolution.dfy
diff options
context:
space:
mode:
authorGravatar leino <unknown>2014-12-12 20:46:48 -0800
committerGravatar leino <unknown>2014-12-12 20:46:48 -0800
commit91c4d57eb84d5d15e011902a1da1b70131e5a222 (patch)
tree6794bafdc71f6bc31c8d09496c3435658bbfc144 /Test/dafny0/CoResolution.dfy
parent62a3e97eb61cbee0d523297ccad1f2d3bcf871c3 (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/CoResolution.dfy')
-rw-r--r--Test/dafny0/CoResolution.dfy72
1 files changed, 38 insertions, 34 deletions
diff --git a/Test/dafny0/CoResolution.dfy b/Test/dafny0/CoResolution.dfy
index 57a593fe..dfa99dd6 100644
--- a/Test/dafny0/CoResolution.dfy
+++ b/Test/dafny0/CoResolution.dfy
@@ -2,32 +2,34 @@
// RUN: %diff "%s.expect" "%t"
module TestModule {
- copredicate P(b: bool)
- {
- !b && Q(null)
- }
+ class TestClass {
+ copredicate P(b: bool)
+ {
+ !b && Q(null)
+ }
- copredicate Q(a: array<int>)
- {
- a == null && P(true)
- }
+ copredicate Q(a: array<int>)
+ {
+ a == null && P(true)
+ }
- copredicate S(d: set<int>)
- {
- this.Undeclared#[5](d) && // error: 'Undeclared#' is undeclared
- Undeclared#[5](d) && // error: 'Undeclared#' is undeclared
- this.S#[5](d) &&
- S#[5](d) &&
- S#[_k](d) // error: _k is not an identifier in scope
- }
+ copredicate S(d: set<int>)
+ {
+ this.Undeclared#[5](d) && // error: 'Undeclared#' is undeclared
+ Undeclared#[5](d) && // error: 'Undeclared#' is undeclared
+ this.S#[5](d) &&
+ S#[5](d) &&
+ S#[_k](d) // error: _k is not an identifier in scope
+ }
- colemma CM(d: set<int>)
- {
- var b;
- b := this.S#[5](d);
- b := S#[5](d);
- this.CM#[5](d);
- CM#[5](d);
+ colemma CM(d: set<int>)
+ {
+ var b;
+ b := this.S#[5](d);
+ b := S#[5](d);
+ this.CM#[5](d);
+ CM#[5](d);
+ }
}
}
@@ -63,19 +65,21 @@ module GhostCheck2 {
}
module Mojul0 {
- copredicate D()
- reads this; // error: copredicates are not allowed to have a reads clause -- WHY NOT?
- {
- true
- }
+ class MyClass {
+ copredicate D()
+ reads this; // error: copredicates are not allowed to have a reads clause -- WHY NOT?
+ {
+ true
+ }
- copredicate NoEnsuresPlease(m: nat)
- ensures NoEnsuresPlease(m) ==> m < 100; // error: a copredicate is not allowed to have an 'ensures' clause
- {
- m < 75
- }
+ copredicate NoEnsuresPlease(m: nat)
+ ensures NoEnsuresPlease(m) ==> m < 100; // error: a copredicate is not allowed to have an 'ensures' clause
+ {
+ m < 75
+ }
- // Note, 'decreases' clauses are also disallowed on copredicates, but the parser takes care of that
+ // Note, 'decreases' clauses are also disallowed on copredicates, but the parser takes care of that
+ }
}
module Mojul1 {