summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar qunyanm <unknown>2015-11-17 13:13:40 -0800
committerGravatar qunyanm <unknown>2015-11-17 13:13:40 -0800
commit2cde0265070d65f738b9ee236f7246e765536f08 (patch)
treea73a6005d3f1367af628a21e0c5566e5332e2414
parent962052e98513945981e3fed49e374642d1ed4aa0 (diff)
Fix issue 107. Instead of writing out StaticReceiverExpr as null valued
LiteralExpr, write out its type instead.
-rw-r--r--Source/Dafny/Compiler.cs6
-rw-r--r--Test/dafny4/Bug107.dfy16
-rw-r--r--Test/dafny4/Bug107.dfy.expect6
3 files changed, 26 insertions, 2 deletions
diff --git a/Source/Dafny/Compiler.cs b/Source/Dafny/Compiler.cs
index 82795480..8f199da4 100644
--- a/Source/Dafny/Compiler.cs
+++ b/Source/Dafny/Compiler.cs
@@ -2310,7 +2310,9 @@ namespace Microsoft.Dafny {
Contract.Requires(expr != null);
if (expr is LiteralExpr) {
LiteralExpr e = (LiteralExpr)expr;
- if (e.Value == null) {
+ if (e is StaticReceiverExpr) {
+ wr.Write(TypeName(e.Type, wr));
+ } else if (e.Value == null) {
wr.Write("({0})null", TypeName(e.Type, wr));
} else if (e.Value is bool) {
wr.Write((bool)e.Value ? "true" : "false");
@@ -2394,7 +2396,7 @@ namespace Microsoft.Dafny {
wr.Write(".@{0}", sf.CompiledName);
wr.Write(sf.PostString);
} else {
- TrParenExpr(e.Obj, wr, inLetExprBody);
+ TrExpr(e.Obj, wr, inLetExprBody);
wr.Write(".@{0}", e.Member.CompileName);
}
diff --git a/Test/dafny4/Bug107.dfy b/Test/dafny4/Bug107.dfy
new file mode 100644
index 00000000..56965d92
--- /dev/null
+++ b/Test/dafny4/Bug107.dfy
@@ -0,0 +1,16 @@
+// RUN: %dafny /compile:3 "%s" > "%t"
+// RUN: %diff "%s.expect" "%t"
+
+method Main()
+{
+ var f := Inc;
+ print(f(4));
+}
+
+function method Inc(x: int): int
+{
+ x + 2
+}
+
+
+
diff --git a/Test/dafny4/Bug107.dfy.expect b/Test/dafny4/Bug107.dfy.expect
new file mode 100644
index 00000000..eaa3aa54
--- /dev/null
+++ b/Test/dafny4/Bug107.dfy.expect
@@ -0,0 +1,6 @@
+
+Dafny program verifier finished with 3 verified, 0 errors
+Program compiled successfully
+Running...
+
+6 \ No newline at end of file