dotnet / dotnet/fsharp

[<TailCall>] attribute gives incorrect warning in many examples

Open
#18,780 14 comments 0 reactions 0 assignees View on GitHub
Area-Compiler-Optimization Area-Diagnostics Bug
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

This code compiles fine:

```fsharp
[]
let rec fib a b = seq {
yield a
yield! fib b (a + b)
}

let fibonacci = fib 0 1
```
But the following minor change produces the message: `The member or function 'fib' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.`

```fsharp
[]
let rec fib a b = seq {
yield a
if true then
yield! fib b (a + b)
}

let fibonacci = fib 0 1
```

**Related information**

Provide any related information (optional):

* Pop!_OS 22.04
* VS Code: 1.102.2
* TargetFramework: net9.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.