summaryrefslogtreecommitdiff
path: root/Test
diff options
context:
space:
mode:
authorGravatar Jason Koenig <unknown>2012-07-12 18:42:54 -0700
committerGravatar Jason Koenig <unknown>2012-07-12 18:42:54 -0700
commitc71f8edce17944b5198ac968da17c19c96b39877 (patch)
treeafb3ae33425416064369f8c93ab5bbc798cf2d39 /Test
parent2ee898b3b9c55b8347182562b8b0a92aeda223e1 (diff)
Dafny: fixed bug in which old locals were not properly forbidden from being modified during refinement
Diffstat (limited to 'Test')
-rw-r--r--Test/dafny0/Answer6
-rw-r--r--Test/dafny0/RefinementModificationChecking.dfy22
-rw-r--r--Test/dafny0/runtest.bat3
3 files changed, 30 insertions, 1 deletions
diff --git a/Test/dafny0/Answer b/Test/dafny0/Answer
index fc434600..41a42319 100644
--- a/Test/dafny0/Answer
+++ b/Test/dafny0/Answer
@@ -1593,6 +1593,12 @@ LiberalEquality.dfy(37,14): Error: arguments must have the same type (got Weird<
LiberalEquality.dfy(52,14): Error: arguments must have the same type (got array<int> and array<bool>)
3 resolution/type errors detected in LiberalEquality.dfy
+-------------------- RefinementModificationChecking.dfy --------------------
+RefinementModificationChecking.dfy(16,4): Error: cannot assign to variable defined previously
+RefinementModificationChecking.dfy(17,4): Error: cannot assign to variable defined previously
+RefinementModificationChecking.dfy(18,4): Error: cannot assign to field defined previously
+3 resolution/type errors detected in RefinementModificationChecking.dfy
+
-------------------- SmallTests.dfy --------------------
SmallTests.dfy(30,11): Error: index out of range
Execution trace:
diff --git a/Test/dafny0/RefinementModificationChecking.dfy b/Test/dafny0/RefinementModificationChecking.dfy
new file mode 100644
index 00000000..887c3595
--- /dev/null
+++ b/Test/dafny0/RefinementModificationChecking.dfy
@@ -0,0 +1,22 @@
+
+ghost module R1 {
+ var f: int;
+ method m(y: set<int>) returns (r: int)
+ {
+ var t := y;
+ }
+}
+
+ghost module R2 refines R1 {
+ var g: nat;
+ method m ...
+ {
+ ...;
+ var x := 3;
+ t := {1}; // bad: previous local
+ r := 3; // bad: out parameter
+ f := 4; // bad: previous field
+ x := 6; // fine: new local
+ g := 34;// fine: new field
+ }
+}
diff --git a/Test/dafny0/runtest.bat b/Test/dafny0/runtest.bat
index 60b544c7..3b4e6e19 100644
--- a/Test/dafny0/runtest.bat
+++ b/Test/dafny0/runtest.bat
@@ -22,7 +22,8 @@ for %%f in (TypeTests.dfy NatTypes.dfy SmallTests.dfy Definedness.dfy
LoopModifies.dfy Refinement.dfy RefinementErrors.dfy
ReturnErrors.dfy ReturnTests.dfy ChainingDisjointTests.dfy
CallStmtTests.dfy MultiSets.dfy PredExpr.dfy LetExpr.dfy
- Predicates.dfy Skeletons.dfy Maps.dfy LiberalEquality.dfy) do (
+ Predicates.dfy Skeletons.dfy Maps.dfy LiberalEquality.dfy
+ RefinementModificationChecking.dfy) do (
echo.
echo -------------------- %%f --------------------
%DAFNY_EXE% /compile:0 /print:out.bpl.tmp /dprint:out.dfy.tmp %* %%f