From d64c49333b5d2a25b542a1385881d346d2e8b88c Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 17 Jul 2023 15:21:38 +0200 Subject: [PATCH 1/2] warnlevel 0 examples added --- .../CompilerOptions/fsc/warn/warn.fs | 2 ++ .../CompilerOptions/fsc/warn/warn_level0.fs | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn.fs index e2e857a0dd..42ba827de6 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 c1be78e9dc..41be1c5d3f 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,16 @@ // #NoMT #CompilerOptions + +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 () From 66b5b18aa34f9aeee2fc4eba0fbaaf9b4b1ef63c Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 17 Jul 2023 15:45:31 +0200 Subject: [PATCH 2/2] Info level diagnostics not displayed at warn:0 setting --- src/Compiler/Driver/CompilerDiagnostics.fs | 2 +- .../CompilerOptions/fsc/warn/warn_level0.fs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index 7e32d78911..9b4f02e9d4 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_level0.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn_level0.fs index 41be1c5d3f..f86e84e25f 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn_level0.fs +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn_level0.fs @@ -1,5 +1,9 @@ // #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