-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Tail-Recursion for the Dafny-to-Rust compiler (#5668)
This PR fixes #5647 I added the corresponding test. <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
1845b42
commit 5521689
Showing
8 changed files
with
221 additions
and
151 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using System; | ||
using System.Configuration; | ||
using System.IO; | ||
using System.Linq; | ||
using Dafny; | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5647.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,28 @@ | ||
// RUN: %testDafnyForEachCompiler "%s" | ||
|
||
// Verify shadowing | ||
|
||
function {:tailrecursion} GetSum( | ||
a_b': nat, | ||
ac_c: string) | ||
: string | ||
{ | ||
if a_b' == 0 then | ||
ac_c | ||
else | ||
var j := a_b'; | ||
var a_b' := if a_b' % 2 == 0 then "1" else "0"; | ||
GetSum(j - 1, ac_c + a_b') | ||
} | ||
|
||
function GetSumAuto(x: nat, y: nat): nat | ||
decreases y - x | ||
{ | ||
if x >= y then y else | ||
1 + GetSumAuto(x + 1, y) | ||
} | ||
|
||
method Main() { | ||
print GetSum(10, ""), "\n"; | ||
print GetSumAuto(0, 5); | ||
} |
2 changes: 2 additions & 0 deletions
2
Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5647.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 @@ | ||
1010101010 | ||
10 |
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 @@ | ||
Tail-Recursion for the Dafny-to-Rust compiler |