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
Looking at the viper encoding, we find that the ternary expression in function h is encoded as
var N2: Int
// first, h is called
N2 := h_41fccf1_F(i_V0_CN0 - 1)
// only then do we desugar the ternary expression
res_V0_CN1 := (i_V0_CN0 == 0 ? 0 : N2)
Clearly, this is wrong. I think that the most appropriate solution here is to always require that a ternary expression is pure. As such, the example above would be rejected because we would call a non-pure function in a ternary operation. This does not limit expressiveness, because we could always use a ghost if instead.
The text was updated successfully, but these errors were encountered:
Alternatively, we could encode an impure ternary operator as an if statement. While convenient to overcome Go‘s shortage of a ternary operator, this encoding might be more surprising than just rejecting such ternary operators
Alternatively, we could encode an impure ternary operator as an if statement. While convenient to overcome Go‘s shortage of a ternary operator, this encoding might be more surprising than just rejecting such ternary operators
Yeah, I think that would be too surprising, and I don't see a good reason for doing that transformation because a ghost if is always acceptable in the contexts where a non-pure conditional expression was accepted before this PR.
Reported by Conradin Laux.
In the file below, function
h2
verifies just fine, but functionh
does not, even though it computes the same value ash2
using a ternary expression.Looking at the viper encoding, we find that the ternary expression in function
h
is encoded asClearly, this is wrong. I think that the most appropriate solution here is to always require that a ternary expression is pure. As such, the example above would be rejected because we would call a non-pure function in a ternary operation. This does not limit expressiveness, because we could always use a ghost if instead.
The text was updated successfully, but these errors were encountered: