Fix missing TailCall warning in Sequential in use scope, #17897 (#17927)

This commit is contained in:
dawe 2024-10-29 12:19:27 +01:00 коммит произвёл GitHub
Родитель 6860329821
Коммит d566f53680
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 30 добавлений и 0 удалений

Просмотреть файл

@ -1,5 +1,6 @@
### Fixed
* Fix missing TailCall warning in Sequential in use scope ([PR #17927](https://github.com/dotnet/fsharp/pull/17927))
* Fix false negatives for passing null to "obj" arguments. Only "obj | null" can now subsume any type ([PR #17757](https://github.com/dotnet/fsharp/pull/17757))
* Fix internal error when calling 'AddSingleton' and other overloads only differing in generic arity ([PR #17804](https://github.com/dotnet/fsharp/pull/17804))
* Fix extension methods support for non-reference system assemblies ([PR #17799](https://github.com/dotnet/fsharp/pull/17799))

Просмотреть файл

@ -792,6 +792,7 @@ let CheckModuleBinding cenv (isRec: bool) (TBind _ as bind) =
// warn for recursive calls in TryWith/TryFinally operations
exprs |> Seq.iter (checkTailCall true)
| Expr.Op(args = exprs) -> exprs |> Seq.iter (checkTailCall insideSubBindingOrTry)
| Expr.Sequential(expr2 = expr2) -> checkTailCall insideSubBindingOrTry expr2
| _ -> ()
checkTailCall false bodyExpr

Просмотреть файл

@ -473,6 +473,34 @@ namespace N
"The member or function 'f' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." }
]
[<FSharp.Test.FactForNETCOREAPP>]
let ``Warn for rec call in Sequential in use scope`` () =
"""
namespace N
module M =
[<TailCall>]
let rec f () =
let path = System.IO.Path.GetTempFileName()
use file = System.IO.File.Open(path, System.IO.FileMode.Open)
printfn "Hi!"
f ()
"""
|> FSharp
|> withLangVersion80
|> compile
|> shouldFail
|> withResults [
{ Error = Warning 3569
Range = { StartLine = 11
StartColumn = 13
EndLine = 11
EndColumn = 14 }
Message =
"The member or function 'f' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." }
]
[<FSharp.Test.FactForNETCOREAPP>]
let ``Warn for invalid tailcalls in async expression`` () =
"""