Skip to content

TailCallAttribute does warn on non-tail-recursive async function with try-with or try-finally block #16322

@jwosty

Description

@jwosty

I'm liking the new non-tail-recursion warning, however it looks like it's missing a case.

Repro steps

Compile this code with F# 8:

[<TailCall>]
let rec g x =
    try
        g (x + 1)
    with e ->
        raise (InvalidOperationException("Operation has failed", e))

[<TailCall>]
let rec gAsync x = async {
    try
        return! gAsync (x + 1)
    with e ->
        return raise (InvalidOperationException("Operation has failed", e))
}

Expected behavior

Both g and gAsync should produce Warning FS3569 : The member or function 'g' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.

Actual behavior

Only g produces FS3569.

This is similarly missed for try-finally blocks

See also

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions