Whiley / WhileyCompiler

The Whiley Compiler (WyC)
http://whiley.org
Apache License 2.0
217 stars 36 forks source link

Flow Typing Specification Elements #1099

Open DavePearce opened 2 years ago

DavePearce commented 2 years ago

This doesn't type check, but looks technically legit (Reference_Valid_39):

type List is &{int data, null|List next }

method fill(List l, int v)
ensures l->data == v
ensures (l->next is List) ==> *(l->next) == old(*(l->next)):
    l->data = v

The problem is that it won't retype l, even though it makes sense to do so in this context.

DavePearce commented 2 years ago

I did manage to workaround this with a property:

property unchanged2({int data, null|List next} node)
// My data is unchanged
where node.data == old(node.data)
// Everything else is also unchanged
where unchanged(node.next)