Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/9.0.100.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Fixed

* Fix wrong TailCall warning ([Issue #17604](https://github.com/dotnet/fsharp/issues/17604), [PR #17637](https://github.com/dotnet/fsharp/pull/17637))
* Compiler hangs when compiling inline recursive invocation ([Issue #17376](https://github.com/dotnet/fsharp/issues/17376), [PR #17394](https://github.com/dotnet/fsharp/pull/17394))
* Fix reporting IsFromComputationExpression only for CE builder type constructors and let bindings. ([PR #17375](https://github.com/dotnet/fsharp/pull/17375))
* Optimize simple mappings in comprehensions when the body of the mapping has `let`-bindings and/or sequential expressions before a single yield. ([PR #17419](https://github.com/dotnet/fsharp/pull/17419))
Expand Down
8 changes: 8 additions & 0 deletions src/Compiler/Checking/TailCallChecks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ type TailCall =
static member YesFromVal (g: TcGlobals) (v: Val) = TailCall.Yes(TailCall.IsVoidRet g v)

static member YesFromExpr (g: TcGlobals) (expr: Expr) =
let yesFromTType (t: TType) =
if isUnitTy g t then
TailCall.Yes TailCallReturnType.MustReturnVoid
else
TailCall.Yes TailCallReturnType.NonVoid

match expr with
| ValUseAtApp(valRef, _) -> TailCall.Yes(TailCall.IsVoidRet g valRef.Deref)
| Expr.Const(constType = constType) -> yesFromTType constType
| Expr.Match(exprType = exprType) -> yesFromTType exprType
| _ -> TailCall.Yes TailCallReturnType.NonVoid

member x.AtExprLambda =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1722,3 +1722,22 @@ module M =
|> withLangVersion80
|> compile
|> shouldSucceed

[<FSharp.Test.FactForNETCOREAPP>]
let ``Don't warn for tail rec call returning unit`` () =
"""
namespace N

module M =

[<TailCall>]
let rec go (args: string list) =
match args with
| [] -> ()
| "--" :: _ -> ()
| arg :: args -> go args
"""
|> FSharp
|> withLangVersion80
|> compile
|> shouldSucceed