Modifies clause error on a changed object
问题 How can I state (in Dafny) an " ensures " guarantee that the object returned by a method will be "new", i.e., will not be the same as an object used anywhere else (yet)? The following code shows a minimal example: method newArray(a:array<int>) returns (b:array<int>) requires a != null ensures b != null ensures a != b ensures b.Length == a.Length+1 { b := new int[a.Length+1]; } class Testing { var test : array<int>; method doesnotwork() requires this.test!=null requires this.test.Length > 10;