-
Notifications
You must be signed in to change notification settings - Fork 277
Adds support for function calls within contracts #5893
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
Adds support for function calls within contracts #5893
Conversation
Contracts definitions often makes use of elaborate predicates, which could be written on a separate functions. Therefore, function contracts should be able to accept functions as part of their specifications. Signed-off-by: Felipe R. Monteiro <felisous@amazon.com>
Codecov Report
@@ Coverage Diff @@
## develop #5893 +/- ##
===========================================
+ Coverage 72.95% 73.03% +0.07%
===========================================
Files 1425 1429 +4
Lines 154281 154708 +427
===========================================
+ Hits 112561 112990 +429
+ Misses 41720 41718 -2
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.
This seems a reasonable and necessary step to get this working. I don't know the contract code as well as I should. Is there an option to ignore / disregard / drop the contracts? If so, does this add significant extra overhead? My feeling is probably not but I am not sure.
Contracts are only added if you run Function contracts and invariants:
--replace-call-with-contract <fun>
replace calls to fun with fun's contract
--replace-all-calls-with-contracts
as above for all functions with a contract
--enforce-contract <fun> wrap fun with an assertion of its contract
--enforce-all-contracts as above for all functions with a contract So you can choose which functions should use contracts or if they should be applied to all of them. I guess this confirms that there won't be any extra significant overhead. Did I answer your question, @martin-cs ? |
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.
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, thanks.
@feliperodri yes and sorry for not getting back to you sooner. One minor concern -- what happens if there is recursion via the contracts? |
Contracts definitions often makes use of elaborate predicates,
which could be written on a separate functions. Therefore,
function contracts should be able to accept functions
as part of their specifications.
Signed-off-by: Felipe R. Monteiro felisous@amazon.com