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/11.0.100.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Fixed

* Honor `--nowarn` and `--warnaserror` for warnings emitted during command-line option parsing ([Issue #19576](https://github.com/dotnet/fsharp/issues/19576), [PR #19776](https://github.com/dotnet/fsharp/pull/19776))
* Fix `[<return: X>]` prefix attributes being silently dropped on class members, and fix false-positive `AllowMultiple=false` errors when `[<X>]` and `[<return: X>]` are applied to the same binding. ([Issue #17904](https://github.com/dotnet/fsharp/issues/17904), [Issue #19020](https://github.com/dotnet/fsharp/issues/19020), [PR #19738](https://github.com/dotnet/fsharp/pull/19738))
* Fix attributes on return type of unparenthesized tuple methods being silently dropped from IL. ([Issue #462](https://github.com/dotnet/fsharp/issues/462), [PR #19714](https://github.com/dotnet/fsharp/pull/19714))
* Fix internal error FS0073 "Undefined or unsolved type variable" in IlxGen when nested inline SRTP functions with multiple overloads leave unsolved typars in the non-witness codegen path. ([Issue #19709](https://github.com/dotnet/fsharp/issues/19709), [PR #19710](https://github.com/dotnet/fsharp/pull/19710))
Expand Down
7 changes: 4 additions & 3 deletions src/Compiler/Driver/fsc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@ type IDiagnosticsLoggerProvider =

type CapturingDiagnosticsLogger with

/// Commit the delayed diagnostics via a fresh temporary logger of the right kind.
member x.CommitDelayedDiagnostics(diagnosticsLoggerProvider: IDiagnosticsLoggerProvider, tcConfigB, exiter) =
let diagnosticsLogger = diagnosticsLoggerProvider.CreateLogger(tcConfigB, exiter)
x.CommitDelayedDiagnostics diagnosticsLogger
x.CommitDelayedDiagnostics(GetDiagnosticsLoggerFilteringByScopedNowarn(tcConfigB.diagnosticsOptions, diagnosticsLogger))

/// The default DiagnosticsLogger implementation, reporting messages to the Console up to the maxerrors maximum
type ConsoleLoggerProvider() =
Expand Down Expand Up @@ -578,7 +577,9 @@ let main1
SetThreadDiagnosticsLoggerNoUnwind diagnosticsLogger

// Forward all errors from flags
delayForFlagsLogger.CommitDelayedDiagnostics diagnosticsLogger
delayForFlagsLogger.CommitDelayedDiagnostics(
GetDiagnosticsLoggerFilteringByScopedNowarn(tcConfigB.diagnosticsOptions, diagnosticsLogger)
)

if not tcConfigB.continueAfterParseFailure then
AbortOnError(diagnosticsLogger, exiter)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace CompilerOptions.Fsc

open Xunit
open FSharp.Test
open FSharp.Test.Compiler

/// Regression tests for https://github.com/dotnet/fsharp/issues/19576
module ``Nowarn for command-line option warnings`` =

[<Fact>]
let ``command-line option warning is emitted`` () =
FSharp "module Module"
|> withOptions [ "--extraoptimizationloops:1" ]
|> ignoreWarnings
|> compile
|> shouldSucceed
|> withWarningCode 75
|> ignore

[<Fact>]
let ``--nowarn suppresses command-line option warning`` () =
FSharp "module Module"
|> withOptions [ "--extraoptimizationloops:1"; "--nowarn:75" ]
|> compile
|> shouldSucceed

[<Fact>]
let ``--nowarn suppresses only the targeted warning`` () =
FSharp "module Module"
|> withOptions [ "--extraoptimizationloops:1"; "--test:NoSuchTestFlag"; "--nowarn:75" ]
|> ignoreWarnings
|> compile
|> shouldSucceed
|> withWarningCode 1063
|> ignore

[<Fact>]
let ``--nowarn 3551 suppresses duplicate source file warning`` () =
let file =
SourceCodeFileKind.Fs(
{ FileName = "test.fs"
SourceText = Some """printfn "Hello" """ }
)

fsFromString file
|> FS
|> asExe
|> withAdditionalSourceFile file
|> withNoWarn 3551
|> compile
|> shouldSucceed

[<Fact>]
let ``--warnaserror+ promotes command-line option warning to error`` () =
FSharp "module Module"
|> withOptions [ "--warnaserror+"; "--extraoptimizationloops:1" ]
|> compile
|> shouldFail
|> withErrorCode 75
|> ignore

[<Fact>]
let ``--warnaserror+ with --nowarn suppresses rather than errors`` () =
FSharp "module Module"
|> withOptions [ "--warnaserror+"; "--extraoptimizationloops:1"; "--nowarn:75" ]
|> compile
|> shouldSucceed

[<Fact>]
let ``--warnaserror 75 with --nowarn 75 still errors because specific warnaserror wins`` () =
FSharp "module Module"
|> withOptions [ "--warnaserror:75"; "--extraoptimizationloops:1"; "--nowarn:75" ]
|> compile
|> shouldFail
|> withErrorCode 75
|> ignore
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@
<Compile Include="CompilerOptions\fsc\Platform.fs" />
<Compile Include="CompilerOptions\fsc\times\times.fs" />
<Compile Include="CompilerOptions\fsc\warn\warn.fs" />
<Compile Include="CompilerOptions\fsc\warn\nowarn_for_cmdline_warnings.fs" />
<Compile Include="CompilerOptions\fsc\warnon\warnon.fs" />
<Compile Include="CompilerOptions\fsc\reference.fs" />
<Compile Include="CompilerOptions\fsc\reflectionfree.fs" />
Expand Down
Loading