From 9fc3952ae7740f55f48563fdccfce76c95bad1c3 Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Fri, 13 Oct 2017 11:52:35 -0700 Subject: [PATCH] undo #3536 (#3746) (#3749) * undo https://github.com/Microsoft/visualfsharp/pull/3536 * undo https://github.com/Microsoft/visualfsharp/pull/3536 --- src/fsharp/LowerCallsAndSeqs.fs | 3 ++- tests/fsharp/core/seq/test.fsx | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/fsharp/LowerCallsAndSeqs.fs b/src/fsharp/LowerCallsAndSeqs.fs index 7e6ba07fe..9dfde6b63 100644 --- a/src/fsharp/LowerCallsAndSeqs.fs +++ b/src/fsharp/LowerCallsAndSeqs.fs @@ -394,6 +394,7 @@ let LowerSeqExpr g amap overallExpr = | None -> None +(* | Expr.LetRec(binds,e2,m,_) when // Restriction: only limited forms of "let rec" in sequence expressions can be handled by assignment to state local values @@ -422,7 +423,7 @@ let LowerSeqExpr g amap overallExpr = Some res4 | None -> None - +*) | Expr.Match (spBind,exprm,pt,targets,m,ty) when targets |> Array.forall (fun (TTarget(vs,_e,_spTarget)) -> isNil vs) -> // lower all the targets. abandon if any fail to lower let tgl = targets |> Array.map (fun (TTarget(_vs,e,_spTarget)) -> Lower false isTailCall noDisposeContinuationLabel currentDisposeContinuationLabel e) |> Array.toList diff --git a/tests/fsharp/core/seq/test.fsx b/tests/fsharp/core/seq/test.fsx index ab6e84be3..b1a59d8b5 100644 --- a/tests/fsharp/core/seq/test.fsx +++ b/tests/fsharp/core/seq/test.fsx @@ -572,6 +572,7 @@ module InfiniteSequenceExpressionsExecuteWithFiniteResources = yield! seqThreeRecCapturingOne r } + // // These tests will stackoverflow or out-of-memory if the above functions are not compiled to "sequence epression tailcalls", // i.e. by compiling them to a state machine let tests() = @@ -697,8 +698,22 @@ module InfiniteSequenceExpressionsExecuteWithFiniteResources = *) -InfiniteSequenceExpressionsExecuteWithFiniteResources.tests() - +// Tests disabled due to bug https://github.com/Microsoft/visualfsharp/issues/3743 +//InfiniteSequenceExpressionsExecuteWithFiniteResources.tests() + + // This is the additional test case related to bug https://github.com/Microsoft/visualfsharp/issues/3743 + let TestRecFuncInSeq() = + let factorials = + [ for x in 0..10 do + let rec factorial x = + match x with + | 0 -> 1 + | x -> x * factorial(x - 1) + yield factorial x + ] + + for f in factorials do printf "%i" f + TestRecFuncInSeq() (*--------------------------------------------------------------------------- !* wrap up -- GitLab