Skip to content

Commit c271484

Browse files
T-GroKevinRansom
andauthored
<WarningLevel>0 should work also for "Information" diagnostics, tests extended (#15608)
* warnlevel 0 examples added * Info level diagnostics not displayed at warn:0 setting --------- Co-authored-by: Kevin Ransom (msft) <[email protected]>
1 parent 440a519 commit c271484

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/Compiler/Driver/CompilerDiagnostics.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ type PhasedDiagnostic with
388388
match x.Exception with
389389
| DiagnosticEnabledWithLanguageFeature (_, _, _, enabled) -> enabled
390390
| _ ->
391-
(severity = FSharpDiagnosticSeverity.Info)
391+
(severity = FSharpDiagnosticSeverity.Info && level > 0)
392392
|| (severity = FSharpDiagnosticSeverity.Warning && level >= x.WarningLevel)
393393

394394
/// Indicates if a diagnostic should be reported as an informational

tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warn/warn.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ module TestCompilerWarningLevel =
1111
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"warn_level0.fs"|])>]
1212
let ``warn_level0_fs --warn:0`` compilation =
1313
compilation
14+
|> withLangVersionPreview
1415
|> asExe
1516
|> withOptions ["--warn:0"]
1617
|> compileAndRun
1718
|> shouldSucceed
19+
|> withDiagnostics []
1820

1921
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"warn_level1.fs"|])>]
2022
let ``warn_level1_fs --warn:1 --warnaserror:52`` compilation =
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
11
// #NoMT #CompilerOptions
2+
3+
[<NoComparison>]
4+
/// Meh - Informational diagnostics "XML comment is not placed on a valid language element."
5+
type A = int
6+
7+
let x = 10
8+
// Normally a The result of this equality expression has type 'bool' and is implicitly discarded.
9+
x = 20
10+
11+
let mul x y = x * y
12+
// Normally a warning
13+
[<TailCall>]
14+
let rec fact n acc =
15+
if n = 0
16+
then acc
17+
else (fact (n - 1) (mul n acc)) + 23
18+
19+
// Normally a 'Main module of program is empty: nothing will happen when it is run' warning
220
()

0 commit comments

Comments
 (0)