-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix/issue-2485-sequentials-stack-overflow (#2495)
* * Switches Sequentials to an imperative impl for efficiency and to not blow up stack * * Further simplifications * * Switches to tail recursion * Adds unit-test * * Adds note on #2485 to changelog * Add release notes for beta 10. Co-authored-by: Florian Verdonck <[email protected]>
- Loading branch information
Showing
4 changed files
with
72 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module Fantomas.Core.Tests.ASTTransformerTests | ||
|
||
#if RELEASE | ||
open NUnit.Framework | ||
open FsUnit | ||
open FSharp.Compiler.Text | ||
open FSharp.Compiler.Xml | ||
open FSharp.Compiler.Syntax | ||
open FSharp.Compiler.SyntaxTrivia | ||
|
||
[<Test>] | ||
let ``avoid stack-overflow in long array/list, 2485`` () = | ||
let testIdent = Ident("Test", Range.Zero) | ||
|
||
let mkStringExpr () = | ||
SynExpr.Const( | ||
SynConst.String((System.Guid.NewGuid().ToString("N"), SynStringKind.Regular, Range.Zero)), | ||
Range.Zero | ||
) | ||
|
||
let longArrayExpr: SynExpr = | ||
let rec mkArray count childExpr = | ||
if count = 20_000 then | ||
childExpr | ||
else | ||
mkArray | ||
(count + 1) | ||
(SynExpr.Sequential( | ||
DebugPointAtSequential.SuppressNeither, | ||
true, | ||
mkStringExpr (), | ||
childExpr, | ||
Range.Zero | ||
)) | ||
|
||
SynExpr.ArrayOrListComputed(true, mkArray 0 (mkStringExpr ()), Range.Zero) | ||
|
||
let rootNode = | ||
Fantomas.Core.AstTransformer.astToNode | ||
Range.Zero | ||
[] | ||
[ SynModuleOrNamespace( | ||
[ testIdent ], | ||
false, | ||
SynModuleOrNamespaceKind.AnonModule, | ||
[ SynModuleDecl.Expr(longArrayExpr, Range.Zero) ], | ||
PreXmlDoc.Empty, | ||
[], | ||
None, | ||
Range.Zero, | ||
{ ModuleKeyword = None | ||
NamespaceKeyword = None } | ||
) ] | ||
|
||
Assert.Pass() | ||
#endif |
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