-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #4860 ### Description - Fix crash by adding missing error report ### How has this been tested? - Added CLI test for crash <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
1 parent
33edb8b
commit 19759cf
Showing
8 changed files
with
57 additions
and
11 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
29 changes: 29 additions & 0 deletions
29
Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/constructorInsteadOfTuple.dfy
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// RUN: ! %resolve "%s" > "%t" | ||
// RUN: %diff "%s.expect" "%t" | ||
|
||
datatype Expr = | ||
| Const(value: int) | ||
| Var(name: string) | ||
| Add(left: Expr, right: Expr) | ||
| Mult(left: Expr, right: Expr) | ||
|
||
function Optimize(expr: Expr): Expr | ||
{ | ||
match expr | ||
case Const(value) => Const(value) | ||
case Var(name) => Var(name) | ||
case Add(left, right) => | ||
match (Optimize(left), Optimize(right)) | ||
case (Const(lv), Const(rv)) => Const(lv + rv) | ||
case (Const(0), rv) => rv | ||
case (lv, Const(0)) => lv | ||
case (lv, rv) => Add(lv, rv) | ||
case Mult(left, right) => | ||
match (Optimize(left), Optimize(right)) | ||
case (Const(lv), Const(rv)) => Const(lv * rv) | ||
case (Const(0), _) => Const(0) | ||
case (_, Const(0)) => Const(0) | ||
case (Const(1), rv) => rv | ||
case (lv, Const(1)) => lv | ||
case (lv, rv) => Mult(lv, rv) | ||
} |
2 changes: 2 additions & 0 deletions
2
...IntegrationTests/TestFiles/LitTests/LitTest/patterns/constructorInsteadOfTuple.dfy.expect
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
constructorInsteadOfTuple.dfy(21,21): Error: found constructor Mult but expected a 2-tuple | ||
1 resolution/type errors detected in constructorInsteadOfTuple.dfy |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
- Fix crash that could occur when using a constructor in a match pattern where a tuple was expected |