diff options
author | qunyanm <unknown> | 2016-02-05 15:18:29 -0800 |
---|---|---|
committer | qunyanm <unknown> | 2016-02-05 15:18:29 -0800 |
commit | 74d1631a4724739dbb897c74713f54c4d060e781 (patch) | |
tree | 0b67e150cd3ca2e32bb07d3991c61a7920ea717b /Test/dafny4 | |
parent | 4f0b823bdc1be13c2589cc46f650ab57d29e7117 (diff) |
Fix issue 125. Add the missing case 2 and 3 with refinement and opened imports.
For the following situation
module LibA {
// ...things declared here...
}
module LibB {
// ...things declared here...
}
module R {
import opened LibA
// ...things declared here...
}
module S refines R {
import opened LibB
// ...declared here...
}
1. If module R declares a TopLevelDecl “G”, then we should report an error if S
attempts to declare an incompatible TopLevelDecl “G”. Dafny does this already.
2. If LibA declares a TopLevelDecl “G” but R does not directly declare any
TopLevelDecl G”, then we should also issue an error for any TopLevelDecl “G”
in S. This behavior is missing in Dafny.
3. If each of LibA and LibB declares some TopLevelDecl “G”, but neither R nor S
directly declares any TopLevelDecl “G”, then no error should be issued, and
any use of “G” in S should resolve to the “G” in LibA. This behavior is missing
in Dafny.
Diffstat (limited to 'Test/dafny4')
-rw-r--r-- | Test/dafny4/Bug125.dfy | 82 | ||||
-rw-r--r-- | Test/dafny4/Bug125.dfy.expect | 2 |
2 files changed, 84 insertions, 0 deletions
diff --git a/Test/dafny4/Bug125.dfy b/Test/dafny4/Bug125.dfy new file mode 100644 index 00000000..916dd3f8 --- /dev/null +++ b/Test/dafny4/Bug125.dfy @@ -0,0 +1,82 @@ +// RUN: %dafny /compile:0 "%s" > "%t"
+// RUN: %diff "%s.expect" "%t"
+
+abstract module AbstractModuleA
+{
+ type T
+}
+
+abstract module AbstractModuleB
+{
+ import opened AMA : AbstractModuleA
+
+ method Foo(t:T)
+}
+
+abstract module AbstractModuleC refines AbstractModuleB
+{
+ import opened AMA2 : AbstractModuleA
+}
+
+module LibA {
+ class G {
+ static function f(x:int) : bool {
+ x >= 10
+ }
+ }
+
+ function g() : bool {
+ true
+ }
+}
+
+module LibB {
+ class G {
+ static function f(x:int) : bool {
+ x < 10
+ }
+ }
+
+ function g() : bool {
+ false
+ }
+}
+
+module R {
+ import opened LibA
+}
+
+module S refines R {
+ import opened LibB
+ method m() {
+ assert g(); // should be LibA.g
+ }
+
+ method m1() {
+ assert G.f(20); // should be LibA.G.f
+ }
+}
+
+
+module Library {
+
+ class T { }
+
+}
+
+
+
+module A {
+
+ import opened Library
+ class T {
+ }
+}
+
+
+
+module B refines A {
+
+ datatype T = MakeT(int) // illegal for the same reason as above, but Dafny fails to issue an error
+
+}
diff --git a/Test/dafny4/Bug125.dfy.expect b/Test/dafny4/Bug125.dfy.expect new file mode 100644 index 00000000..c87e2af2 --- /dev/null +++ b/Test/dafny4/Bug125.dfy.expect @@ -0,0 +1,2 @@ +
+Dafny program verifier finished with 10 verified, 0 errors
|