summaryrefslogtreecommitdiff
path: root/Test/dafny0/TypeParameters.dfy
diff options
context:
space:
mode:
authorGravatar rustanleino <unknown>2011-02-17 23:46:15 +0000
committerGravatar rustanleino <unknown>2011-02-17 23:46:15 +0000
commit320a0392daf9cbb9d4d2b0d0c0ee66c0392f858f (patch)
treee0beded0a34f1483851a1880f00bda98cadaea3c /Test/dafny0/TypeParameters.dfy
parent94025aeed7bffe21b5be543c63dce7e9b255fce5 (diff)
Dafny:
* Big change: Add type and allocatedness information everywhere in the Boogie translation. This not only fixes some potential soundness problems (see Test/dafny1/TypeAntecedents.dfy), but it also gives more information about the program. On the downside, it also requires discharging more antecedents in order to use some axioms. Another downside is that overall performance has gone down (however, this may be just an indirect consequence of the change, as it was in one investigated case). * Increase the applicability of function axioms (extending the coarse-grain function/module height mechanism used as an antecedent of function axioms). (Internally, this uses the new canCall mechanism.) * Extend language with "allocated( Expr )" expressions, which for any type of expression "Expr" says that "Expr" is allocated and has the expected type. * More details error messages about ill-defined expressions (internally, by using CheckWellformedness instead of "assert IsTotal") * Add axioms about idempotence of set union and intersection * The compiler does not support (the experimental feature) coupling invariants, so generate error if the compiler ever gets one * In the implementation, combine common behavior of MatchCaseStmt and MatchCaseExpr into a superclass MatchCase * Fixed error in translation of while(*)
Diffstat (limited to 'Test/dafny0/TypeParameters.dfy')
-rw-r--r--Test/dafny0/TypeParameters.dfy26
1 files changed, 26 insertions, 0 deletions
diff --git a/Test/dafny0/TypeParameters.dfy b/Test/dafny0/TypeParameters.dfy
index 61a0019b..7aaf5ad3 100644
--- a/Test/dafny0/TypeParameters.dfy
+++ b/Test/dafny0/TypeParameters.dfy
@@ -132,3 +132,29 @@ method IsRogerCool(n: int)
assert RogerThat(2 < 3 && n < n && n < n+1); // same here; cool, huh?
}
}
+
+// ----------------------
+
+class TyKn_C<T> {
+ var x: T;
+ function G(): T;
+ method M() returns (t: T);
+}
+
+class TyKn_K {
+ function F(): int { 176 }
+}
+
+method TyKn_Main(k0: TyKn_K) {
+ var c := new TyKn_C<TyKn_K>;
+ var k1: TyKn_K;
+
+ assert k0 != null ==> k0.F() == 176;
+ assert k1 != null ==> k1.F() == 176;
+
+ assert c.x != null ==> c.x.F() == 176; // the Dafny encoding needs the canCall mechanism to verify this
+ assert c.G() != null ==> c.G().F() == 176; // ditto
+ call k2 := c.M();
+ assert k2 != null ==> k2.F() == 176; // the canCall mechanism does the trick here, but so does the encoding
+ // via k2's where clause
+}