Skip to content

TailCall attribute incorrectly warning #17604

@Smaug123

Description

@Smaug123

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

Metadata

Metadata

Assignees

Labels

Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

Type

No type

Projects

Status

New

Relationships

None yet

Development

No branches or pull requests

Issue actions