Recursive sequence expression containing recursive definition doesn't run in finite space
Open
Area-Compiler-StateMachines
Feature Improvement
Impact-Low
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
This small example causes a stack overflow, but shouldn't:
```
let rec loop r = seq {
if r > 0 then
let rec unused() = unused()
yield r
yield! loop r
}
printfn "%i" (Seq.nth 10000000 (loop 1))
```
Removing the conditional or replacing the unused recursive definition with an unused non-recursive definition both appear to result in the expected behavior of constant stack space usage.
Contributor guide
Assessment
This issue has not been assessed yet.