Skip to content

Commit

Permalink
undo #3536 (#3746)
Browse files Browse the repository at this point in the history
* undo #3536

* undo #3536
  • Loading branch information
dsyme authored and KevinRansom committed Oct 13, 2017
1 parent 68f4187 commit 503d167
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/fsharp/LowerCallsAndSeqs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 17 additions & 2 deletions tests/fsharp/core/seq/test.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() =
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 503d167

Please sign in to comment.