diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index 7e32d789119..9b4f02e9d4e 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -388,7 +388,7 @@ type PhasedDiagnostic with match x.Exception with | DiagnosticEnabledWithLanguageFeature (_, _, _, enabled) -> enabled | _ -> - (severity = FSharpDiagnosticSeverity.Info) + (severity = FSharpDiagnosticSeverity.Info && level > 0) || (severity = FSharpDiagnosticSeverity.Warning && level >= x.WarningLevel) /// Indicates if a diagnostic should be reported as an informational diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn.fs index e2e857a0ddb..42ba827de61 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn.fs +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn.fs @@ -11,10 +11,12 @@ module TestCompilerWarningLevel = [] let ``warn_level0_fs --warn:0`` compilation = compilation + |> withLangVersionPreview |> asExe |> withOptions ["--warn:0"] |> compileAndRun |> shouldSucceed + |> withDiagnostics [] [] let ``warn_level1_fs --warn:1 --warnaserror:52`` compilation = diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn_level0.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn_level0.fs index c1be78e9dc3..f86e84e25f7 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn_level0.fs +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn_level0.fs @@ -1,2 +1,20 @@ // #NoMT #CompilerOptions + +[] +/// Meh - Informational diagnostics "XML comment is not placed on a valid language element." +type A = int + +let x = 10 +// Normally a The result of this equality expression has type 'bool' and is implicitly discarded. +x = 20 + +let mul x y = x * y +// Normally a warning +[] +let rec fact n acc = + if n = 0 + then acc + else (fact (n - 1) (mul n acc)) + 23 + +// Normally a 'Main module of program is empty: nothing will happen when it is run' warning ()