Closed JunmingZhao42 closed 6 days ago
The problem here is that, in order for all arguments to have copy semantics, we need to explicitly copy the IArray
used to represent <1, 2>
. The issue would be fixed by something like this:
unfold pred(x)
copied_x := create_slice(x)
fold pred(copied_x)
function_call(copied_x)
// this would only be needed if the predicate is in the post condition
unfold pred(copied_x)
fold pred(x)
This could be added automatically by scanning the predicates in the pre- and postconditions of the called function.
Issues arise if we have more complicated examples like the following:
predicate marker()
method foo(x: Int)
requires x != 0 ==> marker()
method bar() {
var x: Int
if (x != 0) {
inhale marker()
}
foo(x)
}
This might be complicated to generate with the transpiler.
Note: inhale my_array(test)
should be fold my_array(test)
, as unfolding the predicate my_array
would prove false, by providing 2 write permissions to the struct.
The fix we agreed on is to try to encode everything in the predicate s.t. we only have pre-/postconditions of the following type:
requires predicate(x, y, ...)
ensures predicate(x, y, ...)
We can then collect these annotations and generate unfol/fold statements when doing the method call.
The fix we agreed on is to try to encode everything in the predicate s.t. we only have pre-/postconditions of the following type:
requires predicate(x, y, ...) ensures predicate(x, y, ...)
We can then collect these annotations and generate unfol/fold statements when doing the method call.
What about post conditions like ensures x == old(x)
when x
is of type Int
?
Currently if an array argument is used when calling another function, the transpiler adds
create_slice()
of the original array which seems to drop the predicates of the original array. For example:In
main()
function when callingtuple_equal(test)
, there's a copy oftest
created in the transpiled silver code, where the copied one doesn't preservemy_array()
.