I have a simple class with autocontracts in Dafny, that creates a new instance of itself.
But Dafny says that "call might violate context's modifies clause" when I call foo.Add()
inside Bar
method
I can't tell why I'm getting this error since the class does not have any attributes
Am I missing something?
class {:autocontracts} Foo {
predicate Valid()
constructor() { }
method Add() returns (b:bool)
method Bar() returns (fo:Foo)
ensures fresh(fo)
{
fo := new Foo();
var i := 0;
while(i < 3)
modifies fo
invariant fo.Valid()
{
var ret := fo.Add(); //call might violate context's modifies clause Verifier
i := 1 + i;
}
}
}
Dafny Version at VSCode
the installed Dafny version is the latest known: 3.9.0.41003 = 3.9.0