"....must be allocated in the two-state function's previous state" #1902
-
I don't know what this error means: datatype IncomingMessage = IncomingMessage(id: int)
datatype OutgoingMessage = OutgoingMessage(id: int)
class TestClass {
twostate predicate onMessageSpec(inMessage: IncomingMessage, outMessage: OutgoingMessage) {
true
}
method onMessage(message: IncomingMessage) returns (answer: OutgoingMessage)
modifies this
ensures onMessageSpec(message, answer) {
}
} The error message is:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I've hit this a bunch myself, especially while working on dafny-lang/libraries#37 which involves repeating a common post-condition many times. :P Currently, all parameters to a two-state definition must be allocated before the previous state. This is so expressions using You have more flexibility when making assertions in, for example, the body of a method, since you will only hit an error if you actually attempt to apply I'd love to have a way of relaxing this restriction, but haven't put any thought into what the language feature would look like yet. |
Beta Was this translation helpful? Give feedback.
I've hit this a bunch myself, especially while working on dafny-lang/libraries#37 which involves repeating a common post-condition many times. :P
Currently, all parameters to a two-state definition must be allocated before the previous state. This is so expressions using
old(...)
are always well-formed, as otherwise you can attempt to read heap state that didn't actually exist in the previous state of the heap.You have more flexibility when making assertions in, for example, the body of a method, since you will only hit an error if you actually attempt to apply
old(...)
to an expression that refers to objects that were not already allocated on entry to the method. But atwostate
abstract…