gobra
gobra copied to clipboard
Exception when sending a constant to a channel with a defined channel type
The following program causes a violation during encoding:
type ChannelMsgType int
const ChannelMsg ChannelMsgType = 42
pred sendInvariant(v ChannelMsgType) {
true
}
requires acc(channel.SendChannel(), 1/2)
requires channel.SendGivenPerm() == sendInvariant!<_!>
requires channel.SendGotPerm() == PredTrue!<!>
func sendMsg(channel chan ChannelMsgType) {
fold sendInvariant!<_!>(ChannelMsg)
fold PredTrue!<!>()
assert acc(channel.SendChannel(), _) && sendInvariant!<_!>(ChannelMsg)
assert acc(channel.SendChannel(), _) && channel.SendGivenPerm()(ChannelMsg)
channel <- ChannelMsg
}
The channel encoding checks whether the message type is identical to the channel type. This is however not the case here because constant propagation replaces ChannelMsg with 42, i.e., an integer literal.