-
Notifications
You must be signed in to change notification settings - Fork 260
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
feat: Allow more assumptions in library backend #4545
Merged
robin-aws
merged 5 commits into
dafny-lang:master
from
robin-aws:allow-more-assumptions-in-library-backend
Sep 15, 2023
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9c09b0e
Allow more assumption cases in libraries
robin-aws bd6b999
Add new test cases for externs with axiom attributes
robin-aws 81c996a
PR feedback (revert change to flag pre/postconditions on externs with…
robin-aws c867ce5
Merge branch 'master' into allow-more-assumptions-in-library-backend
robin-aws 286cbda
Merge branch 'master' into allow-more-assumptions-in-library-backend
robin-aws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,22 +25,35 @@ bool allowedInLibraries | |
allowedInLibraries: false); | ||
public static AssumptionDescription ExternFunction = new( | ||
issue: "Function with [{:extern}] attribute.", | ||
mitigation: "Turn into a [method] with [modifies *] or test thoroughly for lack of side effects.", | ||
mitigationIETF: "SHOULD use [method] with [modifies *] instead.", | ||
isExplicit: false, | ||
allowedInLibraries: false); | ||
public static AssumptionDescription ExternWithPrecondition = new( | ||
issue: "Declaration with [{:extern}] has a requires clause.", | ||
mitigation: "Test any external callers (maybe with [/testContracts]).", | ||
mitigationIETF: "MUST test any external callers.", | ||
isExplicit: false, | ||
allowedInLibraries: false); | ||
public static AssumptionDescription ExternWithPostcondition = new( | ||
issue: "Declaration with [{:extern}] has a ensures clause.", | ||
mitigation: "Test external callee (maybe with [/testContracts]).", | ||
mitigationIETF: "MUST test external callee.", | ||
mitigation: "Turn into a [method] with [modifies {}] or test thoroughly for lack of side effects.", | ||
mitigationIETF: "SHOULD use [method] with [modifies {}] instead.", | ||
isExplicit: false, | ||
allowedInLibraries: false); | ||
|
||
public static AssumptionDescription ExternWithPrecondition(bool hasAxiomAttribute) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know I originally suggested this design, but now I'm thinking this should be treated as such:
|
||
return new( | ||
issue: | ||
hasAxiomAttribute | ||
? "Declaration with [{:extern}] and [{:axiom}] has a requires clause." | ||
: "Declaration with [{:extern}] has a requires clause.", | ||
mitigation: "Test any external callers (maybe with [/testContracts]).", | ||
mitigationIETF: "MUST test any external callers.", | ||
isExplicit: false, | ||
allowedInLibraries: hasAxiomAttribute); | ||
} | ||
|
||
public static AssumptionDescription ExternWithPostcondition(bool hasAxiomAttribute) { | ||
return new( | ||
issue: | ||
hasAxiomAttribute | ||
? "Declaration with [{:extern}] and [{:axiom}] has a ensures clause." | ||
: "Declaration with [{:extern}] has a ensures clause.", | ||
mitigation: "Test external callee (maybe with [/testContracts]).", | ||
mitigationIETF: "MUST test external callee.", | ||
isExplicit: false, | ||
allowedInLibraries: hasAxiomAttribute); | ||
} | ||
|
||
public static AssumptionDescription AssumeStatement(bool hasAxiomAttribute) { | ||
return new( | ||
issue: | ||
|
@@ -56,24 +69,23 @@ public static AssumptionDescription AssumeStatement(bool hasAxiomAttribute) { | |
? "SHOULD replace with [assert] and prove." | ||
: "MUST replace with [assert] and prove or add [{:axiom}].", | ||
isExplicit: false, | ||
allowedInLibraries: false | ||
allowedInLibraries: hasAxiomAttribute | ||
); | ||
} | ||
public static AssumptionDescription MayNotTerminate = new( | ||
issue: "Method may not terminate (uses [decreases *]).", | ||
mitigation: "Provide a valid [decreases] clause.", | ||
mitigationIETF: "SHOULD provide a valid [decreases] clause.", | ||
isExplicit: false, | ||
// This isn't unsound but it's hard to imagine useful libraries | ||
// with non-terminating methods. If we ever want to offer something like a | ||
// top-level event loop driver we can revisit. | ||
allowedInLibraries: false); | ||
allowedInLibraries: true); | ||
public static AssumptionDescription HasTerminationFalseAttribute = new( | ||
issue: "Trait method calls may not terminate (uses [{:termination false}]).", | ||
mitigation: "Remove if possible.", | ||
mitigationIETF: "MUST remove [{:termination false}] or justify.", | ||
isExplicit: false, | ||
allowedInLibraries: false); | ||
// DISCUSS: There is no realistic mitigation or way to attach :axiom, | ||
// and no other way to share traits in a library. | ||
allowedInLibraries: true); | ||
public static AssumptionDescription ForallWithoutBody = new( | ||
issue: "Definition contains [forall] statement with no body.", | ||
mitigation: "Provide a body.", | ||
|
@@ -86,12 +98,6 @@ public static AssumptionDescription AssumeStatement(bool hasAxiomAttribute) { | |
mitigationIETF: "MUST provide a body.", | ||
isExplicit: false, | ||
allowedInLibraries: false); | ||
public static AssumptionDescription HasConcurrentAttribute = new( | ||
issue: "Declaration has [{:concurrent}] attribute.", | ||
mitigation: "Manually review and test in a concurrent setting.", | ||
mitigationIETF: "MUST manually review and test in a concurrent setting.", | ||
isExplicit: false, | ||
allowedInLibraries: false); | ||
|
||
public static AssumptionDescription NoBody(bool isGhost) { | ||
return new( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
Turning it into a method allows for non-determinism that may occur, but if we have
modifies {}
then we'll really want to know that it has no side effects.