You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
kind: enhancementEnhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafnypart: documentationDafny's reference manual, tutorial, and other materials
trait Entries<T> {
var entries: array<T>methodCopy() returns (x: array<T>)
ensuresfresh(x) && x[..] == entries[..]
{
x :=new T[entries.Length](
i requires 0 <= i < entries.Length
reads entries
// ^^^^^^^ Insufficient reads clause to read field
=> entries[i]);
}
}
Command to run and resulting output
Paste in VSCode and see the error message.
What happened?
I did not get it why it could not read the array "entries" since it's in a method.
It turns out, "entries" is a shortcut for "this.entries", which means that this expression requires "reads this".
I think I would have immediately spotted it if, instead of the error message:
Insufficient reads clause to read field
I would have had the following error message, at least because "this" is implicit.
Insufficient reads clause to read field 'entries', perhaps try adding reads 'this' in the enclosing scope
What type of operating system are you experiencing the problem on?
kind: enhancementEnhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafnypart: documentationDafny's reference manual, tutorial, and other materials
Activity
Fix: Enhanced "insufficient reads clause to read field" (#5265)