Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main to release/dev17.12 #17643

Merged
merged 5 commits into from
Aug 30, 2024
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
2 changes: 2 additions & 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 All @@ -13,6 +14,7 @@
* Fixed checking failure when `global` namespace is involved with enabled GraphBasedChecking ([PR #17553](/~https://github.com/dotnet/fsharp/pull/17553))
* Add missing byte chars notations, enforce limits in decimal notation in byte char & string (Issues [#15867](/~https://github.com/dotnet/fsharp/issues/15867), [#15868](/~https://github.com/dotnet/fsharp/issues/15868), [#15869](/~https://github.com/dotnet/fsharp/issues/15869), [PR #15898](/~https://github.com/dotnet/fsharp/pull/15898))
* Parentheses analysis: keep extra parentheses around unit & tuples in method definitions. ([PR #17618](/~https://github.com/dotnet/fsharp/pull/17618))
* Consider `open type` used when the type is an enum and any of the enum cases is used unqualified. ([PR #17628](/~https://github.com/dotnet/fsharp/pull/17628))

### Added

Expand Down
12 changes: 6 additions & 6 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="10.0.0-alpha.1.24426.2">
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="10.0.0-alpha.1.24428.1">
<Uri>/~https://github.com/dotnet/source-build-reference-packages</Uri>
<Sha>6c26545ca7999a4192df6899ea9ed4eaa950d367</Sha>
<Sha>6bcf90f99d13da86c5e9753a6f34b6484673d0a0</Sha>
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
</Dependency>
<!-- Intermediate is necessary for source build. -->
Expand Down Expand Up @@ -42,14 +42,14 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.24426.3">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.24429.3">
<Uri>/~https://github.com/dotnet/arcade</Uri>
<Sha>e3bdd9a0f2a65fe037ba1adb2261eea48a840fa4</Sha>
<Sha>b3f0996b03bfab02a8d9e1669ddb6f12b35634a5</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="9.0.0-beta.24426.3">
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="9.0.0-beta.24429.3">
<Uri>/~https://github.com/dotnet/arcade</Uri>
<Sha>e3bdd9a0f2a65fe037ba1adb2261eea48a840fa4</Sha>
<Sha>b3f0996b03bfab02a8d9e1669ddb6f12b35634a5</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="optimization.windows_nt-x64.MIBC.Runtime" Version="1.0.0-prerelease.23614.4">
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"perl": "5.38.2.2"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24426.3",
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24429.3",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2"
}
}
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
5 changes: 5 additions & 0 deletions src/Compiler/Service/ServiceAnalysis.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ module UnusedOpens =
if not entity.IsNamespace && not entity.IsFSharpModule then
for fv in entity.MembersFunctionsAndValues do
fv

if entity.IsEnum then
for field in entity.FSharpFields do
if field.IsStatic && field.IsLiteral then
field
|]

HashSet<_>(symbols, symbolHash)
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
16 changes: 15 additions & 1 deletion tests/FSharp.Compiler.Service.Tests/ProjectAnalysisTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5603,13 +5603,25 @@ open SomeUsedModuleContainingFunction
open SomeUsedModuleContainingExtensionMember
open SomeUsedModuleContainingActivePattern
open SomeUsedModuleContainingUnion
open type System.DayOfWeek // Used, should not appear.
open type System.DateTimeKind // Unused, should appear.

type FSharpEnum1 = X = 1 | Y = (1 <<< 1) | Z = (1 <<< 2)
type FSharpEnum2 = H = 1 | I = (1 <<< 1) | J = (1 <<< 2)

open type FSharpEnum1 // Used, should not appear.
open type FSharpEnum2 // Unused, should appear.

type UseTheThings(i:int) =
member x.Value = Dictionary<int,int>() // use something from System.Collections.Generic, as a constructor
member x.UseSomeUsedModuleContainingFunction() = g 3
member x.UseSomeUsedModuleContainingActivePattern(ActivePattern g) = g
member x.UseSomeUsedModuleContainingExtensionMember() = (3).Q
member x.UseSomeUsedModuleContainingUnion() = A
member x.UseEnumCase = Monday // Use an enum case from System.DayOfWeek.
member x.UseEnumCaseQualified = System.DateTimeKind.Utc // Use a qualified enum case.
member x.UseFSharpEnumCase = Y // Use an enum case from FSharpEnum1.
member x.UseFSharpEnumCaseQualified = FSharpEnum2.J // Use a qualified enum case.
"""
let fileSource1 = SourceText.ofString fileSource1Text
FileSystem.OpenFileForWriteShim(fileName1).Write(fileSource1Text)
Expand Down Expand Up @@ -5637,7 +5649,9 @@ type UseTheThings(i:int) =
(((6, 5), (6, 19)), "open FSharp.Control // unused");
(((7, 5), (7, 16)), "open FSharp.Data // unused");
(((8, 5), (8, 25)), "open System.Globalization // unused");
(((25, 5), (25, 21)), "open SomeUnusedModule")]
(((25, 5), (25, 21)), "open SomeUnusedModule");
(((31, 10), (31, 29)), "open type System.DateTimeKind // Unused, should appear.")
(((37, 10), (37, 21)), "open type FSharpEnum2 // Unused, should appear.")]
unusedOpensData |> shouldEqual expected

[<Theory>]
Expand Down
Loading