-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow more assumptions in library backend (#4545)
The "library backend" which is selected using `--target:lib` and produces `.doo` files is currently more restrictive than the other backends. The common SinglePassCompiler logic rejects features that cannot be compiled such as `assume` statements without `{:axiom}`, but the library backend doesn't actually use that base class. It instead leverages the `Declaration.Assumptions()` method that the auditor uses to identify assumptions. `AssumptionDescription`s have a `allowedInLibraries` flag to indicate whether they should cause build errors when trying to build a `.doo` file, and the initial version was intentionally very conservative. This PR switches the value of this flag for a few cases that are very likely to appear in useful libraries and where the risk of misuse is zero or very low: * `assume {:axiom} ...` - already allowed by other backends. * `decreases *` - not really an assumption, more of a sound specification limitation, and we may even remove this from the auditor as well in the future. * `{:extern}` declarations with `requires` or `ensures` - now allowed only if the declaration also has `{:axiom}`, and this case now creates auditor warnings as well. * ~`{:termination false}` - allowed because there is no mitigation and traits are highly valuable to share in libraries.~ This is worth discussing, and the better alternative may be to support an assumption attribute on the class extending a trait instead, so that the assumption appears in the consumer instead of the library code. (Update: I reverted the change to allow this attribute in libraries and will implement the alternative instead in a separate PR) Also corrected a typo in mitigation text suggesting `modifies *` when it should be `modifies {}` - `modifies *` doesn't even parse. :) <small>By submitting this pull request, I confirm that my contribution is made under the terms of the [MIT license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
- Loading branch information
Showing
8 changed files
with
41 additions
and
25 deletions.
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
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