-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For function postcondition violations, point to the problematic expre…
…ssion branch (#5681) I'm putting this PR on hold, since it increases the size of the generated Boogie. Example: https://diff.corp.amazon.com/compare/9ap5cvpm ### Description If the result of an expression does not satisfy the constraints of its context, then an error is reported in the branch of the expression that does not satisfy the context. Effected contexts: - Function postconditions - Witness expressions - Expression default values - Subset type checks for function call arguments - Assignment to a subset type local Example of improved error reporting: ```dafny function ElseError(x: int): int // previous primary error location ensures ElseError(x) == 0 // related error location { if x == 0 then 0 else 1 // new primary error location } function ThenError(x: int): int // previous primary error location ensures ThenError(x) == 0 // related error location { if x == 0 then 1 // new primary error location else 0 } function CaseError(x: int): int // previous primary error location ensures CaseError(x) == 1 // related error location { match x { case 0 => 1 case 1 => 0 // new primary error location case _ => 1 } } function LetError(x: int): int // previous primary error location ensures LetError(x) == 1 // related error location { var r := 3; r // new primary error location } ``` ### How has this been tested? - Added CLI test `ast/functions/ensuresReporting.dfy` - `ast/subsetTypes/errorReporting.dfy` - `ast/expression/functionCall.dfy` - `ast/statement/localAssignment.dfy` <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> --------- Co-authored-by: Stefan Zetzsche <[email protected]>
- Loading branch information
1 parent
c9fe1be
commit ef1e3bc
Showing
61 changed files
with
825 additions
and
535 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
200 changes: 113 additions & 87 deletions
200
Source/DafnyCore/Verifier/BoogieGenerator.ExpressionWellformed.cs
Large diffs are not rendered by default.
Oops, something went wrong.
405 changes: 405 additions & 0 deletions
405
Source/DafnyCore/Verifier/BoogieGenerator.Functions.Wellformedness.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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.