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

Contracts: History Expressions via "old" monad #3232

Merged
merged 73 commits into from
Jun 18, 2024

Conversation

pi314mm
Copy link
Contributor

@pi314mm pi314mm commented Jun 6, 2024

Add support for History Expressions. This allows an ensures clause to evaluate expressions before the function runs, bing them to anonymous variables and use them after calculating the result to be able to compare to the state before the function evaluation.

Resolves #2803

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@github-actions github-actions bot added the Z-BenchCI Tag a PR to run benchmark CI label Jun 6, 2024
tests/expected/function-contract/history/stub.rs Outdated Show resolved Hide resolved
tests/expected/function-contract/history/clone_pass.rs Outdated Show resolved Hide resolved
rfc/src/rfcs/0009-function-contracts.md Outdated Show resolved Hide resolved
rfc/src/rfcs/0009-function-contracts.md Outdated Show resolved Hide resolved
rfc/src/rfcs/0009-function-contracts.md Outdated Show resolved Hide resolved
rfc/src/rfcs/0009-function-contracts.md Outdated Show resolved Hide resolved
@feliperodri
Copy link
Contributor

@JustusAdam could you give another review?

Copy link
Contributor

@JustusAdam JustusAdam left a 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 otherwise

library/kani_macros/src/sysroot/contracts/shared.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@celinval celinval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a few ui/ tests where the user misuses the API, for example:

  1. User tries to pass an object of type T: !Copy to old.
  2. old has no argument.
  3. old argument is not an expression.
  4. User tries to pass result to old.

Copy link
Contributor

@celinval celinval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the ui tests. I think we need to work on these error messages though. I'm OK with making it a follow up PR, but I'll leave it up to you and @feliperodri.

@celinval celinval dismissed their stale review June 18, 2024 18:29

Blocking issues have been addressed

@feliperodri feliperodri enabled auto-merge (squash) June 18, 2024 18:58
@feliperodri feliperodri merged commit 2971595 into model-checking:main Jun 18, 2024
25 checks passed
@pi314mm pi314mm deleted the old branch June 18, 2024 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-BenchCI Tag a PR to run benchmark CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

History Expression Support for Function Contracts
4 participants