silver
silver copied to clipboard
Add Inhaling expression
@JonasAlaif and I have been working on a new inhaling expression. The purpose of this new expression is that we want to temporarily inhale some assertion to check facts that are inaccessible in the current state. An example of this is a magic wand, where we don't hold its LHS and where we want to check a property in the snapshot of this magic wand.
For example, we can use this expression to define the snapshot of a wand as follows:
field f: Int
method test5(x: Ref, y: Ref)
requires true --* acc(x.f)
requires acc(x.f) --* acc(y.f)
requires inhaling (acc(x.f)) in applying (acc(x.f) --* acc(y.f)) in y.f == 10
{
apply true --* acc(x.f)
apply acc(x.f) --* acc(y.f)
assert y.f == 10
}
The syntax is as follows: inhaling (<assertion>) in <expression>
-
assertionmust be in parenthesis because of a conflict with theinkeyword used for sets. This has been discussed for the applying expression in #216. -
expressionmust be pure.
This PR extends Silver to parse this new expression and adds some test files to check the expected behavior. There is also an implementation for Silicon in viperproject/silicon#848.