summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar qunyanm <unknown>2015-06-04 00:31:16 -0700
committerGravatar qunyanm <unknown>2015-06-04 00:31:16 -0700
commit9a7cc1eaf7dc9006f249ceab7793ccd0b6da40ac (patch)
tree09f953668f120e7bdbf74e916e137f7a877e892e
parent0e63640cbdb2ba154ef1427782ba147717bee3cf (diff)
Generate #requires function for OpaqueFunction.
-rw-r--r--Source/Dafny/Translator.cs2
-rw-r--r--Test/dafny4/Bug82.dfy11
-rw-r--r--Test/dafny4/Bug82.dfy.expect2
3 files changed, 14 insertions, 1 deletions
diff --git a/Source/Dafny/Translator.cs b/Source/Dafny/Translator.cs
index 045ef8d0..e7a8bedf 100644
--- a/Source/Dafny/Translator.cs
+++ b/Source/Dafny/Translator.cs
@@ -1480,7 +1480,7 @@ namespace Microsoft.Dafny {
AddFunctionAxiom(f, FunctionAxiomVisibility.ForeignModuleOnly, f.Body.Resolved);
}
// for body-less functions, at least generate its #requires function
- if (f.Body == null) {
+ if (f.Body == null || IsOpaqueFunction(f)) {
var b = FunctionAxiom(f, FunctionAxiomVisibility.ForeignModuleOnly, null, null);
Contract.Assert(b == null);
}
diff --git a/Test/dafny4/Bug82.dfy b/Test/dafny4/Bug82.dfy
new file mode 100644
index 00000000..bc7ff321
--- /dev/null
+++ b/Test/dafny4/Bug82.dfy
@@ -0,0 +1,11 @@
+// RUN: %dafny /compile:0 "%s" > "%t"
+// RUN: %diff "%s.expect" "%t"
+
+function {:opaque} Reverse(id:int) : int
+
+function RefineToMap(ReverseKey:int->int) : bool
+
+function RefineToMapOfSeqNums() : bool
+{
+ RefineToMap(Reverse)
+}
diff --git a/Test/dafny4/Bug82.dfy.expect b/Test/dafny4/Bug82.dfy.expect
new file mode 100644
index 00000000..73ba063c
--- /dev/null
+++ b/Test/dafny4/Bug82.dfy.expect
@@ -0,0 +1,2 @@
+
+Dafny program verifier finished with 4 verified, 0 errors