-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add opaque/reveal to Gobra #715
Conversation
src/main/scala/viper/gobra/frontend/info/implementation/typing/ExprTyping.scala
Outdated
Show resolved
Hide resolved
src/main/scala/viper/gobra/frontend/info/implementation/typing/ghost/GhostExprTyping.scala
Show resolved
Hide resolved
src/main/scala/viper/gobra/frontend/info/implementation/typing/ghost/GhostMemberTyping.scala
Outdated
Show resolved
Hide resolved
src/test/resources/regressions/features/opaque/opaque-interface-fail1.gobra
Outdated
Show resolved
Hide resolved
src/test/resources/regressions/features/opaque/reveal-closure-fail1.gobra
Outdated
Show resolved
Hide resolved
QUES in question was added as comment on PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I have a few comments, mostly minor things. After they are addressed, this should be ready to merge
src/main/scala/viper/gobra/frontend/info/implementation/typing/ghost/GhostMemberTyping.scala
Outdated
Show resolved
Hide resolved
src/main/scala/viper/gobra/translator/encodings/closures/ClosureSpecsEncoder.scala
Show resolved
Hide resolved
src/test/resources/regressions/features/opaque/opaque-interface-fail1.gobra
Outdated
Show resolved
Hide resolved
src/test/resources/regressions/features/opaque/reveal-closure-fail1.gobra
Outdated
Show resolved
Hide resolved
We currently do not have tests for the following errors:
Is that alright? |
That is fine. I think the only thing missing is disallowing marking interface methods with opaque. After this, we can merge the PR |
Disallowing marking interfaces with opaque should be line 38-40 in StmtTyping.scala, while the error should be exercised by opaque-interface-fail1.gobra. |
oops, I missed this; sorry! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Overview
This pull request implement
opaque
andreveal
for functions and methods in Gobra.Similar to the meaning of
opaque
andreveal
in Dafny (Dafny's reference), anopaque
function does not expose its body by default. The programmer can explicitly reveal the body of a function call usingreveal
. Please refer to opaque-fac2.gobra and opaque-fac3.gobra for examples.Motivation
Not unnecessarily exposing the body of a pure function and hence reducing the context of the solver may increase proof stability and improve performance. This is something that @jcp19 and I plan to investigate in the context of my practical work.
Implementation
opaque
andreveal
are implemented by automatically adding the corresponding annotations on the Viper level.Related pull requests/commits