-
Notifications
You must be signed in to change notification settings - Fork 274
allow contracts on function declarations #5946
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
Conversation
51f2a9f
to
5547367
Compare
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.
This looks nice, but given that tests are failing there obviously are some problems left to be fixed. Nothing blatantly obvious while reviewing the source code, thus requires more debugging.
5547367
to
9573f2b
Compare
All code contracts are failing, which is expected since the regression suite also need to be updated (i.e., move all contracts to function declarations). |
The bit that is missing is to change the scope to the scope used for the parameters when parsing the contract expressions. There should not be a need to change any of the existing tests, the existing syntax continues to work. |
e1ccf25
to
4b80251
Compare
3473ce8
to
7b035e4
Compare
On Wed, 2021-03-17 at 08:09 -0700, Felipe R. Monteiro wrote:
> This looks nice, but given that tests are failing there obviously
> are some problems left to be fixed. Nothing blatantly obvious while
> reviewing the source code, thus requires more debugging.
All code contracts are failing, which is expected since the
regression suite also need to be updated (i.e., move all contracts to
function declarations).
I don't know your use-case fully but one cute feature SPARK has is that
you can put preconditions and postconditions on both the declaration
and definitions of functions. You need that they imply each other but
it allows you to separate the pre/post you use to prove the function
and the pre/post you use as an abstraction in proving other code. It
is really more useful when the code base gets larger but if we are in a
place where we /could/ implement this maybe we should think about if we
/should/.
Cheers,
- Martin
|
Codecov Report
@@ Coverage Diff @@
## develop #5946 +/- ##
===========================================
+ Coverage 74.24% 75.01% +0.77%
===========================================
Files 1431 1431
Lines 155290 155276 -14
===========================================
+ Hits 115290 116483 +1193
+ Misses 40000 38793 -1207
Continue to review full report at Codecov.
|
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.
Looks good to me, but it would be nice to modify some of the existing tests in regression/contract to make use of the new feature. Ideally with all the options now newly available: mixing contracts on declarations and definitions, mixing up their order. Also, what should we expect to happen when both a declaration and a definition have a contract (cf. @martin-cs' comment) - this might mean adding a KNOWNBUG test.
This changes the grammar of the C frontend to allow contracts on function declarations. This also removes the requirement that the contract clauses appear in any particular order.
7b035e4
to
4a50ac1
Compare
This changes the grammar of the C frontend to allow contracts on function
declarations. This also removes the requirement that the contract clauses
appear in any particular order.