fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

`TailCall` attribute incorrectly warning

Open Smaug123 opened this issue 1 year ago • 2 comments

The [<TailCall>] attribute warns about a piece of code which is tail recursive and which empirically is not subject to stack overflows.

Repro steps

Provide the steps required to reproduce the problem:

module Foo =
    [<TailCall>]
    let rec go (args: string list) =
        match args with
        | [] -> ()
        | "--" :: _ -> ()
        | arg :: args -> go args

The second match clause is required. Without that, this compiles successfully. Problem reproduces in debug and release mode.

Expected behavior

Compiles successfully

Actual behavior

Error FS3569 : The member or function 'go' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way. This doesn't seem to be affecting the actual compilation; just a faulty warning.

Known workarounds

none

Related information

Provide any related information (optional):

> dotnet info
.NET SDK:
 Version:           8.0.303
 Commit:            29ab8e3268
 Workload version:  8.0.300-manifests.c915c39d
 MSBuild version:   17.10.4+10fbfbf2e

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  14.5
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /nix/store/qyz2wdl8lqvch8ny038nh0p9sqa9zg5j-dotnet-sdk-8.0.303/sdk/8.0.303/

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      8.0.7
  Architecture: arm64
  Commit:       2aade6beb0

.NET SDKs installed:
  8.0.303 [/nix/store/qyz2wdl8lqvch8ny038nh0p9sqa9zg5j-dotnet-sdk-8.0.303/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.7 [/nix/store/qyz2wdl8lqvch8ny038nh0p9sqa9zg5j-dotnet-sdk-8.0.303/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.7 [/nix/store/qyz2wdl8lqvch8ny038nh0p9sqa9zg5j-dotnet-sdk-8.0.303/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  /Users/patrick/Documents/GitHub/WoofWare.Myriad/global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Smaug123 avatar Aug 25 '24 16:08 Smaug123

@dawedawe Maybe this would ring a bell for you

psfinaki avatar Aug 26 '24 12:08 psfinaki

@dawedawe Maybe this would ring a bell for you

I'll try to find some time in a couple of days to look into it.

dawedawe avatar Aug 26 '24 20:08 dawedawe