-
Notifications
You must be signed in to change notification settings - Fork 830
Closed
Bug
Copy link
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone
Description
Recently I discovered that we got a stack overflow for a function that we had the TailCallAttribute
on. It seems that the check doesn't work well for functions that uses use
to dispose resources.
Repro steps
// Causes as warning which is expected. Causes a stack overflow
[<TailCall>]
let rec example1 () =
let path = Path.GetTempFileName()
use file = File.Open(path, FileMode.Open)
example1 ()
// Does not cause a warning even tough it causes a stack overflow
[<TailCall>]
let rec example2 () =
let path = Path.GetTempFileName()
use file = File.Open(path, FileMode.Open)
printfn "Hi!"
example2 ()
Compile the code above. example1
results in warning as expected. example2
does not result in a warning.
A zip-file with this example is attached. Running dotnet build
only gives a warning for the first function.
RecursionExample.zip
Expected behavior
Both functions should result in warnings regarding the TailCallAttribute
.
Actual behavior
Only example1
results in a warning.
Known workarounds
In code reviews manually check that functions marked with TailCallAttribute
doesn't use use
.
Related information
- Windows 11
- .NET SDK 8.0.403
- FSharp.Core 8.0.401
Metadata
Metadata
Assignees
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.
Type
Projects
Status
Done