From bfd722fb0f5654fac4c3510625e5eec0a09cdfd1 Mon Sep 17 00:00:00 2001 From: qunyanm Date: Tue, 5 Jan 2016 10:14:00 -0800 Subject: Fix issue 116. Add the missing @ for the generated c# code. --- Source/Dafny/Compiler.cs | 3 +-- Test/dafny4/Bug116.dfy | 15 +++++++++++++++ Test/dafny4/Bug116.dfy.expect | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 Test/dafny4/Bug116.dfy create mode 100644 Test/dafny4/Bug116.dfy.expect diff --git a/Source/Dafny/Compiler.cs b/Source/Dafny/Compiler.cs index 264ecf9b..1a99a8af 100644 --- a/Source/Dafny/Compiler.cs +++ b/Source/Dafny/Compiler.cs @@ -2507,8 +2507,7 @@ namespace Microsoft.Dafny { DatatypeValue dtv = (DatatypeValue)expr; Contract.Assert(dtv.Ctor != null); // since dtv has been successfully resolved var typeParams = dtv.InferredTypeArgs.Count == 0 ? "" : string.Format("<{0}>", TypeNames(dtv.InferredTypeArgs, wr)); - - wr.Write("new {0}{1}(", DtName(dtv.Ctor.EnclosingDatatype), typeParams); + wr.Write("new @{0}{1}(", DtName(dtv.Ctor.EnclosingDatatype), typeParams); if (!dtv.IsCoCall) { // For an ordinary constructor (that is, one that does not guard any co-recursive calls), generate: // new Dt_Cons( args ) diff --git a/Test/dafny4/Bug116.dfy b/Test/dafny4/Bug116.dfy new file mode 100644 index 00000000..9fd30597 --- /dev/null +++ b/Test/dafny4/Bug116.dfy @@ -0,0 +1,15 @@ +// RUN: %dafny "%s" > "%t" +// RUN: %diff "%s.expect" "%t" + +datatype struct = S // this is ok + +method Main() +{ + var s := S; // this line generates illegal C# code + print s; +} + + + + + diff --git a/Test/dafny4/Bug116.dfy.expect b/Test/dafny4/Bug116.dfy.expect new file mode 100644 index 00000000..b0cf7300 --- /dev/null +++ b/Test/dafny4/Bug116.dfy.expect @@ -0,0 +1,3 @@ + +Dafny program verifier finished with 2 verified, 0 errors +Compiled assembly into Bug116.exe -- cgit v1.2.3