navigation

EnsureTailCallDiagnosticsInRecursiveFunctions (FL0085)

Introduced in 0.24.2

Cause

Recursive function is not marked as tail-recursive using [<TailCall>] attribute.

Rationale

Tail-recursive functions have no risk of stack overflow and perform better. Adding [<TailCall>] attribute to recursive function makes compiler check that it's indeed tail-recursive and give warning otherwise. <WarningsAsErrors>FS3569</WarningsAsErrors> property in project file will make compiler treat this as warning as error. Requires .NET 8 or later.

How To Fix

Add [<TailCall>] attribute to your function.

Rule Settings

{
    "ensureTailCallDiagnosticsInRecursiveFunctions": {
        "enabled": true
    }
}