Skip to content

Commit 1595946

Browse files
authored
Make unused bindings an error (#18421)
1 parent c01bc47 commit 1595946

File tree

12 files changed

+18
-9
lines changed

12 files changed

+18
-9
lines changed

FSharpBuild.Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<ProtoOutputPath>$(ArtifactsDir)\Bootstrap</ProtoOutputPath>
2929
<ValueTupleImplicitPackageVersion>4.4.0</ValueTupleImplicitPackageVersion>
3030
<WarnOn>$(WarnOn);1182</WarnOn>
31-
<WarningsAsErrors>0025;$(WarningsAsErrors)</WarningsAsErrors>
31+
<WarningsAsErrors>1182;0025;$(WarningsAsErrors)</WarningsAsErrors>
3232
<OtherFlags>$(OtherFlags) --nowarn:3384</OtherFlags>
3333
<OtherFlags>$(OtherFlags) --times --nowarn:75</OtherFlags>
3434
<OtherFlags Condition="$(AdditionalFscCmdFlags) != ''">$(OtherFlags) $(AdditionalFscCmdFlags)</OtherFlags>

buildtools/fslex/fslex.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<TargetFramework>$(FSharpNetCoreProductTargetFramework)</TargetFramework>
66
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
77
<RollForward Condition="'$(BUILDING_USING_DOTNET)' == 'true'">LatestMajor</RollForward>
8-
<NoWarn>$(NoWarn);64;1182;1204</NoWarn> <!--Temporary fix for sourcebuild -->
8+
<NoWarn>$(NoWarn);64;1204;1182</NoWarn> <!--Temporary fix for sourcebuild -->
9+
<OtherFlags>$(OtherFlags) --warnaserror-:1182</OtherFlags>
910
</PropertyGroup>
1011

1112
<PropertyGroup>

buildtools/fsyacc/fsyacc.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<TargetFramework>$(FSharpNetCoreProductTargetFramework)</TargetFramework>
66
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
77
<RollForward Condition="'$(BUILDING_USING_DOTNET)' == 'true'">LatestMajor</RollForward>
8-
<NoWarn>$(NoWarn);64;1182;1204</NoWarn> <!--Temporary fix for sourcebuild -->
8+
<NoWarn>$(NoWarn);64;1204;1182</NoWarn> <!--Temporary fix for sourcebuild -->
9+
<OtherFlags>$(OtherFlags) --warnaserror-:1182</OtherFlags>
910
</PropertyGroup>
1011

1112
<PropertyGroup>

tests/FSharp.Compiler.Service.Tests/EditorTests.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ open FSharp.Compiler.Symbols
99
open FSharp.Compiler.Text
1010
open FSharp.Compiler.Tokenization
1111

12+
#nowarn "1182" // Unused bindings when ignored parsed results etc.
13+
1214
let stringMethods =
1315
[
1416
"Chars"; "Clone"; "CompareTo"; "Contains"; "CopyTo"; "EndsWith";

tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<TargetFrameworks Condition="'$(OS)' == 'Unix' or '$(BUILDING_USING_DOTNET)' == 'true'">$(FSharpNetCoreProductTargetFramework)</TargetFrameworks>
77
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
88
<NoWarn>$(NoWarn);1182</NoWarn> <!-- suppress warning for unused values in FSharp.Compiler.Service.Tests tests, very often checker results are needed, but not used -->
9+
<OtherFlags>$(OtherFlags) --warnaserror-:1182</OtherFlags>
910
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
1011
<UnitTestType>xunit</UnitTestType>
1112
</PropertyGroup>

tests/FSharp.Compiler.Service.Tests/MultiProjectAnalysisTests.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ open FSharp.Compiler.Text
1313
open FSharp.Compiler.Service.Tests.Common
1414
open TestFramework
1515

16+
#nowarn "1182" // Unused bindings when ignored parsed results etc.
17+
1618
let toIList (x: _ array) = x :> IList<_>
1719
let numProjectsForStressTest = 100
1820
let internal checker = FSharpChecker.Create(projectCacheSize=numProjectsForStressTest + 10, useTransparentCompiler = CompilerAssertHelpers.UseTransparentCompiler)

tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PreRelease>true</PreRelease>
1414
<LangVersion>preview</LangVersion>
1515
<NoWarn>$(NoWarn);1182</NoWarn> <!-- suppress warning for unused values in FSharp.Core tests, there are way too many of edge case scenarios tested -->
16-
16+
<OtherFlags>$(OtherFlags) --warnaserror-:1182</OtherFlags>
1717
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
1818
<UnitTestType>xunit</UnitTestType>
1919
<IsTestProject>true</IsTestProject>

vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<OutputType>Library</OutputType>
77
<NoWarn>$(NoWarn);47;75;1182</NoWarn><!-- 1182 - unused bindings, too many of them here -->
88
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
9-
<OtherFlags>$(OtherFlags) --subsystemversion:6.00</OtherFlags>
9+
<OtherFlags>$(OtherFlags) --subsystemversion:6.00 --warnaserror-:1182</OtherFlags>
1010
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
1111
</PropertyGroup>
1212

vsintegration/src/FSharp.VS.FSI/sessions.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type internal EventWrapper() =
4141

4242
/// Run function application return Some (f x) or None if execution exceeds timeout (in ms).
4343
/// Exceptions raised by f x are caught and reported in DEBUG mode.
44-
let timeoutApp descr timeoutMS (f : 'a -> 'b) (arg:'a) =
44+
let timeoutApp _descr timeoutMS (f : 'a -> 'b) (arg:'a) =
4545
use ev = new EventWrapper()
4646
let mutable r = None
4747
ThreadPool.QueueUserWorkItem(fun _ ->
@@ -57,7 +57,7 @@ let timeoutApp descr timeoutMS (f : 'a -> 'b) (arg:'a) =
5757
"fsi.exe starts the remoting server at the end of it's initialisation sequence.\n" +
5858
"The initialisation sequence takes an observable time (e.g. 2 seconds).\n" +
5959
"Remoting exceptions are to be expected on interrupt/intellisense calls made before that point.\n" +
60-
"Context: " + descr + "\n" +
60+
"Context: " + _descr + "\n" +
6161
"Exception: " + e.ToString()) |> ignore
6262
#endif
6363
None
@@ -285,7 +285,7 @@ let fsiStartInfo channelName sourceFile =
285285
procInfo
286286

287287

288-
let nonNull = function null -> false | (s:string) -> true
288+
let nonNull = function null -> false | (_:string) -> true
289289

290290
/// Represents an active F# Interactive process to which Visual Studio is connected via stdin/stdout/stderr and a remoting channel
291291
type FsiSession(sourceFile) =

vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<PropertyGroup>
66
<TargetFramework>net472</TargetFramework>
77
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
8-
<OtherFlags>$(OtherFlags) --nowarn:3390 --nowarn:3218 --nowarn:1182</OtherFlags>
8+
<OtherFlags>$(OtherFlags) --nowarn:3390 --nowarn:3218 --nowarn:1182 --warnaserror-:1182</OtherFlags>
99
</PropertyGroup>
1010

1111
<ItemGroup>

0 commit comments

Comments
 (0)