Skip to content

Recursive sequence expression containing recursive definition doesn't run in finite space #996

@kbattocchi

Description

@kbattocchi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-StateMachinesSequence, list, task and other state machine compilationFeature ImprovementImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    No type

    Projects

    Status

    In Progress

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions