Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unchecked annotation not respected for inlined postconditions #1136

Open
gsps opened this issue Aug 13, 2021 · 0 comments
Open

Unchecked annotation not respected for inlined postconditions #1136

gsps opened this issue Aug 13, 2021 · 0 comments

Comments

@gsps
Copy link
Contributor

gsps commented Aug 13, 2021

For @synthetic functions we re-assert postconditions at inlined call sites (see

).

The particular way in which this is done, i.e., by let-binding the post condition and then asserting the bound variable subverts existing machinery for leaving certain parts of postconditions unchecked. Namely, conjuncts annotated with @unchecked are filtered out in TypeChecker (see

), but only if they occur directly in the VC to be checked. The indirection (let pc = @unchecked cond; assert(pc) instead of assert(@unchecked cond)) leads to cond being check nonetheless.

This leads to an issue with correct-by-construction postconditions introduced in lowering phases, such as TypeEncoding. In particular, for generic functions f[T](x: T): T we lower to f(T: Object => Boolean, x: { v: Object | T(v) }): { v: Object | T(v) } where f's postcondition has been strengthened by ... && @unchecked res == f'(x) referring to auxiliary function f'(x: Object): Object = ???. That postcondition holds by construction, but cannot be proven automatically, so the above-described bug leads to spurious counter-examples.

See also #1125 for a related discussion on how to control the unchecked behavior in a more fine-grained way. As far as I can tell the split in that PR won't help us in this case, unfortunately, but I'll try to have a closer look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant