From 8c3a04604b452785e28e3d3a9ff208602f87bc95 Mon Sep 17 00:00:00 2001 From: dawe Date: Wed, 7 Feb 2024 17:50:28 +0100 Subject: [PATCH 01/12] use file-specific DiagnosticOptions in ComputeParseAndCheckProject to handle HashDirectives in files correctly --- src/Compiler/Service/TransparentCompiler.fs | 45 +++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index 9f3881ecfd2..4ae62c6ff6e 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -1652,7 +1652,6 @@ type internal TransparentCompiler let! tcInfo, ilAssemRef, assemblyDataResult, checkedImplFiles = ComputeProjectExtras bootstrapInfo snapshotWithSources - let diagnosticsOptions = bootstrapInfo.TcConfig.diagnosticsOptions let fileName = DummyFileNameForRangesWithoutASpecificLocation let topAttribs = tcInfo.topAttribs @@ -1665,18 +1664,40 @@ type internal TransparentCompiler SymbolEnv(bootstrapInfo.TcGlobals, tcInfo.tcState.Ccu, Some tcInfo.tcState.CcuSig, bootstrapInfo.TcImports) |> Some - let tcDiagnostics = - DiagnosticHelpers.CreateDiagnostics( - diagnosticsOptions, - true, - fileName, - tcDiagnostics, - suggestNamesForErrors, - bootstrapInfo.TcConfig.flatErrors, - symbolEnv - ) + let getTcDiagnosticsWithFileSpecificOptions (file: FSharpFileSnapshot) = + node { + let isExe = bootstrapInfo.TcConfig.target.IsExe + let isLastCompiland = file.FileName = (projectSnapshot.SourceFileNames |> List.last) + let! fileWithSource = LoadSource file isExe isLastCompiland + let! parsedFile = ComputeParseFile projectSnapshot bootstrapInfo.TcConfig fileWithSource + + let fileSpecificTcConfig = + ApplyNoWarnsToTcConfig(bootstrapInfo.TcConfig, parsedFile.ParsedInput, file.FileName) + + let diagnosticsOptions = fileSpecificTcConfig.diagnosticsOptions + + let tcDiagnostics = + DiagnosticHelpers.CreateDiagnostics( + diagnosticsOptions, + true, + fileName, + tcDiagnostics, + suggestNamesForErrors, + bootstrapInfo.TcConfig.flatErrors, + symbolEnv + ) + + return tcDiagnostics + } + + let! fileTcDiags = + projectSnapshot.SourceFiles + |> Seq.map getTcDiagnosticsWithFileSpecificOptions + |> NodeCode.Parallel + + let fileTcDiags = fileTcDiags |> Array.concat - let diagnostics = [| yield! creationDiags; yield! tcDiagnostics |] + let diagnostics = [| yield! creationDiags; yield! fileTcDiags |] let getAssemblyData () = match assemblyDataResult with From 33b20ae0ad40d1205fbe604bd5df377abc9fc844 Mon Sep 17 00:00:00 2001 From: dawe Date: Thu, 8 Feb 2024 11:36:30 +0100 Subject: [PATCH 02/12] filter diagnostics to the name of the given file and handle diagnostics without a specific location --- src/Compiler/Service/TransparentCompiler.fs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index 4ae62c6ff6e..2daae991d77 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -1664,6 +1664,18 @@ type internal TransparentCompiler SymbolEnv(bootstrapInfo.TcGlobals, tcInfo.tcState.Ccu, Some tcInfo.tcState.CcuSig, bootstrapInfo.TcImports) |> Some + let locationlessTcDiagnostics = + DiagnosticHelpers.CreateDiagnostics( + bootstrapInfo.TcConfig.diagnosticsOptions, + true, + fileName, + tcDiagnostics, + suggestNamesForErrors, + bootstrapInfo.TcConfig.flatErrors, + symbolEnv + ) + |> Array.filter (fun d -> d.FileName = fileName) + let getTcDiagnosticsWithFileSpecificOptions (file: FSharpFileSnapshot) = node { let isExe = bootstrapInfo.TcConfig.target.IsExe @@ -1687,7 +1699,9 @@ type internal TransparentCompiler symbolEnv ) - return tcDiagnostics + let filtered = tcDiagnostics |> Array.filter (fun d -> d.FileName = file.FileName) + + return filtered } let! fileTcDiags = @@ -1697,7 +1711,8 @@ type internal TransparentCompiler let fileTcDiags = fileTcDiags |> Array.concat - let diagnostics = [| yield! creationDiags; yield! fileTcDiags |] + let diagnostics = + [| yield! creationDiags; yield! locationlessTcDiagnostics; yield! fileTcDiags |] let getAssemblyData () = match assemblyDataResult with From e62c29db4e89718b280d6ddda240ceae94d65990 Mon Sep 17 00:00:00 2001 From: dawe Date: Thu, 8 Feb 2024 14:42:42 +0100 Subject: [PATCH 03/12] shuffle the loggers and scopes in ComputeTcIntermediate to respect the hash directives when reporting warnings --- src/Compiler/Service/TransparentCompiler.fs | 63 +++------------------ 1 file changed, 7 insertions(+), 56 deletions(-) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index a95a7db1eb5..557168482b7 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -1193,29 +1193,16 @@ type internal TransparentCompiler tcConfig.flatErrors ) - use _ = - new CompilationGlobalsScope(errHandler.DiagnosticsLogger, BuildPhase.TypeCheck) - // Apply nowarns to tcConfig (may generate errors, so ensure diagnosticsLogger is installed) let tcConfig = ApplyNoWarnsToTcConfig(tcConfig, parsedMainInput, Path.GetDirectoryName mainInputFileName) - // update the error handler with the modified tcConfig - errHandler.DiagnosticOptions <- tcConfig.diagnosticsOptions - let diagnosticsLogger = errHandler.DiagnosticsLogger - //let capturingDiagnosticsLogger = CapturingDiagnosticsLogger("TypeCheck") - - //let diagnosticsLogger = - // GetDiagnosticsLoggerFilteringByScopedPragmas( - // false, - // input.ScopedPragmas, - // tcConfig.diagnosticsOptions, - // capturingDiagnosticsLogger - // ) + let diagnosticsLogger = + GetDiagnosticsLoggerFilteringByScopedPragmas(false, input.ScopedPragmas, tcConfig.diagnosticsOptions, diagnosticsLogger) - //use _ = new CompilationGlobalsScope(diagnosticsLogger, BuildPhase.TypeCheck) + use _ = new CompilationGlobalsScope(diagnosticsLogger, BuildPhase.TypeCheck) //beforeFileChecked.Trigger fileName @@ -1734,6 +1721,7 @@ type internal TransparentCompiler let! tcInfo, ilAssemRef, assemblyDataResult, checkedImplFiles = ComputeProjectExtras bootstrapInfo snapshotWithSources + let diagnosticsOptions = bootstrapInfo.TcConfig.diagnosticsOptions let fileName = DummyFileNameForRangesWithoutASpecificLocation let topAttribs = tcInfo.topAttribs @@ -1746,9 +1734,9 @@ type internal TransparentCompiler SymbolEnv(bootstrapInfo.TcGlobals, tcInfo.tcState.Ccu, Some tcInfo.tcState.CcuSig, bootstrapInfo.TcImports) |> Some - let locationlessTcDiagnostics = + let tcDiagnostics = DiagnosticHelpers.CreateDiagnostics( - bootstrapInfo.TcConfig.diagnosticsOptions, + diagnosticsOptions, true, fileName, tcDiagnostics, @@ -1756,45 +1744,8 @@ type internal TransparentCompiler bootstrapInfo.TcConfig.flatErrors, symbolEnv ) - |> Array.filter (fun d -> d.FileName = fileName) - - let getTcDiagnosticsWithFileSpecificOptions (file: FSharpFileSnapshot) = - node { - let isExe = bootstrapInfo.TcConfig.target.IsExe - let isLastCompiland = file.FileName = (projectSnapshot.SourceFileNames |> List.last) - let! fileWithSource = LoadSource file isExe isLastCompiland - let! parsedFile = ComputeParseFile projectSnapshot bootstrapInfo.TcConfig fileWithSource - - let fileSpecificTcConfig = - ApplyNoWarnsToTcConfig(bootstrapInfo.TcConfig, parsedFile.ParsedInput, file.FileName) - - let diagnosticsOptions = fileSpecificTcConfig.diagnosticsOptions - - let tcDiagnostics = - DiagnosticHelpers.CreateDiagnostics( - diagnosticsOptions, - true, - fileName, - tcDiagnostics, - suggestNamesForErrors, - bootstrapInfo.TcConfig.flatErrors, - symbolEnv - ) - - let filtered = tcDiagnostics |> Array.filter (fun d -> d.FileName = file.FileName) - - return filtered - } - - let! fileTcDiags = - projectSnapshot.SourceFiles - |> Seq.map getTcDiagnosticsWithFileSpecificOptions - |> NodeCode.Parallel - - let fileTcDiags = fileTcDiags |> Array.concat - let diagnostics = - [| yield! creationDiags; yield! locationlessTcDiagnostics; yield! fileTcDiags |] + let diagnostics = [| yield! creationDiags; yield! tcDiagnostics |] let getAssemblyData () = match assemblyDataResult with From c5eb1bc28aad62a646fe2be6224e75f67bee34e6 Mon Sep 17 00:00:00 2001 From: dawe Date: Thu, 8 Feb 2024 17:06:17 +0100 Subject: [PATCH 04/12] add test for transparent compiler respecting nowarn hash directives --- tests/service/ExprTests.fs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/service/ExprTests.fs b/tests/service/ExprTests.fs index 7b35568e38d..1371c24f231 100644 --- a/tests/service/ExprTests.fs +++ b/tests/service/ExprTests.fs @@ -3605,3 +3605,27 @@ let ``Test ProjectForWitnesses4 GetWitnessPassingInfo`` useTransparentCompiler = printfn "actual:\n\n%A" actual actual |> shouldPairwiseEqual expected + +module internal ProjectForNoWarnHashDirective = + + let fileSource1 = """ +module N.M +#nowarn "40" +let rec f = new System.EventHandler(fun _ _ -> f.Invoke(null,null)) +""" + + let createOptions() = createOptionsAux [fileSource1] [] + +[] +[] +[] +let ``Test NoWarn HashDirective`` useTransparentCompiler = + let cleanup, options = ProjectForNoWarnHashDirective.createOptions() + use _holder = cleanup + let exprChecker = FSharpChecker.Create(keepAssemblyContents=true, useTransparentCompiler=useTransparentCompiler) + let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunImmediate + + for e in wholeProjectResults.Diagnostics do + printfn "ProjectForNoWarnHashDirective error: <<<%s>>>" e.Message + + wholeProjectResults.Diagnostics.Length |> shouldEqual 0 From 0b135a6fe1225dc2fd96d1a0bf4344e9779f435c Mon Sep 17 00:00:00 2001 From: dawe Date: Thu, 8 Feb 2024 21:28:07 +0100 Subject: [PATCH 05/12] bring in changes from b47ba47 --- tests/FSharp.Test.Utilities/CompilerAssert.fs | 2 +- tests/FSharp.Test.Utilities/ProjectGeneration.fs | 2 +- tests/service/Common.fs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index 7951ba31d5d..8117e5390ce 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -259,7 +259,7 @@ and Compilation = module rec CompilerAssertHelpers = - let useTransparentCompiler = FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically + let useTransparentCompiler = true let checker = FSharpChecker.Create(suggestNamesForErrors=true, useTransparentCompiler=useTransparentCompiler) // Unlike C# whose entrypoint is always string[] F# can make an entrypoint with 0 args, or with an array of string[] diff --git a/tests/FSharp.Test.Utilities/ProjectGeneration.fs b/tests/FSharp.Test.Utilities/ProjectGeneration.fs index 2236eee988d..74a4eab5b01 100644 --- a/tests/FSharp.Test.Utilities/ProjectGeneration.fs +++ b/tests/FSharp.Test.Utilities/ProjectGeneration.fs @@ -931,7 +931,7 @@ type ProjectWorkflowBuilder ?isExistingProject ) = - let useTransparentCompiler = defaultArg useTransparentCompiler FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically + let useTransparentCompiler = defaultArg useTransparentCompiler true let useGetSource = not useTransparentCompiler && defaultArg useGetSource false let useChangeNotifications = not useTransparentCompiler && defaultArg useChangeNotifications false let autoStart = defaultArg autoStart true diff --git a/tests/service/Common.fs b/tests/service/Common.fs index 8516948626a..11723a53a8a 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -31,7 +31,7 @@ type Async with task.Result // Create one global interactive checker instance -let checker = FSharpChecker.Create(useTransparentCompiler=FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically) +let checker = FSharpChecker.Create(useTransparentCompiler=true) type TempFile(ext, contents: string) = let tmpFile = Path.ChangeExtension(tryCreateTemporaryFileName (), ext) From a949af0fc18ddcaa6ff1633a6ac05072886d4801 Mon Sep 17 00:00:00 2001 From: dawe Date: Fri, 9 Feb 2024 19:11:59 +0100 Subject: [PATCH 06/12] Don't promote informational diagnostics too liberally to Warnings --- src/Compiler/Driver/CompilerDiagnostics.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index 3327aa0a635..3859c44f0cf 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -2176,10 +2176,10 @@ type DiagnosticsLoggerFilteringByScopedPragmas if report then if diagnostic.ReportAsError(diagnosticOptions, severity) then diagnosticsLogger.DiagnosticSink(diagnostic, FSharpDiagnosticSeverity.Error) - elif diagnostic.ReportAsWarning(diagnosticOptions, severity) then - diagnosticsLogger.DiagnosticSink(diagnostic, FSharpDiagnosticSeverity.Warning) elif diagnostic.ReportAsInfo(diagnosticOptions, severity) then diagnosticsLogger.DiagnosticSink(diagnostic, severity) + elif diagnostic.ReportAsWarning(diagnosticOptions, severity) then + diagnosticsLogger.DiagnosticSink(diagnostic, FSharpDiagnosticSeverity.Warning) override _.ErrorCount = diagnosticsLogger.ErrorCount From fccd88bfa060905c9a78919d947122dc6e18386d Mon Sep 17 00:00:00 2001 From: dawe Date: Fri, 9 Feb 2024 19:13:43 +0100 Subject: [PATCH 07/12] Revert "bring in changes from b47ba47" This reverts commit 0b135a6fe1225dc2fd96d1a0bf4344e9779f435c. --- tests/FSharp.Test.Utilities/CompilerAssert.fs | 2 +- tests/FSharp.Test.Utilities/ProjectGeneration.fs | 2 +- tests/service/Common.fs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index 8117e5390ce..7951ba31d5d 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -259,7 +259,7 @@ and Compilation = module rec CompilerAssertHelpers = - let useTransparentCompiler = true + let useTransparentCompiler = FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically let checker = FSharpChecker.Create(suggestNamesForErrors=true, useTransparentCompiler=useTransparentCompiler) // Unlike C# whose entrypoint is always string[] F# can make an entrypoint with 0 args, or with an array of string[] diff --git a/tests/FSharp.Test.Utilities/ProjectGeneration.fs b/tests/FSharp.Test.Utilities/ProjectGeneration.fs index 74a4eab5b01..2236eee988d 100644 --- a/tests/FSharp.Test.Utilities/ProjectGeneration.fs +++ b/tests/FSharp.Test.Utilities/ProjectGeneration.fs @@ -931,7 +931,7 @@ type ProjectWorkflowBuilder ?isExistingProject ) = - let useTransparentCompiler = defaultArg useTransparentCompiler true + let useTransparentCompiler = defaultArg useTransparentCompiler FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically let useGetSource = not useTransparentCompiler && defaultArg useGetSource false let useChangeNotifications = not useTransparentCompiler && defaultArg useChangeNotifications false let autoStart = defaultArg autoStart true diff --git a/tests/service/Common.fs b/tests/service/Common.fs index 11723a53a8a..8516948626a 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -31,7 +31,7 @@ type Async with task.Result // Create one global interactive checker instance -let checker = FSharpChecker.Create(useTransparentCompiler=true) +let checker = FSharpChecker.Create(useTransparentCompiler=FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically) type TempFile(ext, contents: string) = let tmpFile = Path.ChangeExtension(tryCreateTemporaryFileName (), ext) From 2bec620136b0a8e5fa6340504c85bc001b52e72a Mon Sep 17 00:00:00 2001 From: dawe Date: Sat, 10 Feb 2024 11:11:44 +0100 Subject: [PATCH 08/12] extend test to show that old behaviour of DiagnosticsLoggerFilteringByScopedPragmas was wrong --- tests/service/ExprTests.fs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/service/ExprTests.fs b/tests/service/ExprTests.fs index 1371c24f231..6ba7616065f 100644 --- a/tests/service/ExprTests.fs +++ b/tests/service/ExprTests.fs @@ -3612,9 +3612,10 @@ module internal ProjectForNoWarnHashDirective = module N.M #nowarn "40" let rec f = new System.EventHandler(fun _ _ -> f.Invoke(null,null)) +let g() = ([] = []) """ - let createOptions() = createOptionsAux [fileSource1] [] + let createOptions() = createOptionsAux [fileSource1] ["--warnon:3559"] [] [] @@ -3628,4 +3629,8 @@ let ``Test NoWarn HashDirective`` useTransparentCompiler = for e in wholeProjectResults.Diagnostics do printfn "ProjectForNoWarnHashDirective error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> shouldEqual 0 + wholeProjectResults.Diagnostics.Length |> shouldEqual 2 + let infoDiagnostics = + wholeProjectResults.Diagnostics + |> Array.filter (fun d -> d.Severity = FSharpDiagnosticSeverity.Info) + infoDiagnostics.Length |> shouldEqual 2 From 76dd9bce5d1ba6be727c0b591ca47d1adb4f7542 Mon Sep 17 00:00:00 2001 From: dawe Date: Mon, 12 Feb 2024 14:11:39 +0100 Subject: [PATCH 09/12] revert to old and correct severity handling --- src/Compiler/Driver/CompilerDiagnostics.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index 3859c44f0cf..3327aa0a635 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -2176,10 +2176,10 @@ type DiagnosticsLoggerFilteringByScopedPragmas if report then if diagnostic.ReportAsError(diagnosticOptions, severity) then diagnosticsLogger.DiagnosticSink(diagnostic, FSharpDiagnosticSeverity.Error) - elif diagnostic.ReportAsInfo(diagnosticOptions, severity) then - diagnosticsLogger.DiagnosticSink(diagnostic, severity) elif diagnostic.ReportAsWarning(diagnosticOptions, severity) then diagnosticsLogger.DiagnosticSink(diagnostic, FSharpDiagnosticSeverity.Warning) + elif diagnostic.ReportAsInfo(diagnosticOptions, severity) then + diagnosticsLogger.DiagnosticSink(diagnostic, severity) override _.ErrorCount = diagnosticsLogger.ErrorCount From 9dcdbb1679bb29f671348c582abd2efbe2a0c7bc Mon Sep 17 00:00:00 2001 From: dawe Date: Mon, 12 Feb 2024 14:12:36 +0100 Subject: [PATCH 10/12] use `compile` instead of typecheck to let the severity propagation happen --- .../ConstraintSolver/ObjInference.fs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/ObjInference.fs b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/ObjInference.fs index 32950d8ba4c..a4971b2fadb 100644 --- a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/ObjInference.fs +++ b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/ObjInference.fs @@ -34,13 +34,14 @@ let x = deserialize "" |> f""", 3, 9, 3, 28 [] [] let ``Warning is emitted when type Obj is inferred``(code: string, line1: int, col1: int, line2: int, col2: int) = + let code = $"module M\n{code}" FSharp code |> withErrorRanges |> withWarnOn 3559 |> withLangVersion80 - |> typecheck + |> compile |> shouldFail - |> withSingleDiagnostic (Information 3559, Line line1, Col col1, Line line2, Col col2, message) + |> withSingleDiagnostic (Warning 3559, Line (line1 + 1), Col col1, Line (line2 + 1), Col col2, message) let quotableNoWarningCases = [ From ebb1b9e865ed5e07a3cc9dbcdcdf1c55553fff3d Mon Sep 17 00:00:00 2001 From: dawe Date: Mon, 12 Feb 2024 14:15:44 +0100 Subject: [PATCH 11/12] no need to test informational warnings anymore --- tests/service/ExprTests.fs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/service/ExprTests.fs b/tests/service/ExprTests.fs index 6ba7616065f..1371c24f231 100644 --- a/tests/service/ExprTests.fs +++ b/tests/service/ExprTests.fs @@ -3612,10 +3612,9 @@ module internal ProjectForNoWarnHashDirective = module N.M #nowarn "40" let rec f = new System.EventHandler(fun _ _ -> f.Invoke(null,null)) -let g() = ([] = []) """ - let createOptions() = createOptionsAux [fileSource1] ["--warnon:3559"] + let createOptions() = createOptionsAux [fileSource1] [] [] [] @@ -3629,8 +3628,4 @@ let ``Test NoWarn HashDirective`` useTransparentCompiler = for e in wholeProjectResults.Diagnostics do printfn "ProjectForNoWarnHashDirective error: <<<%s>>>" e.Message - wholeProjectResults.Diagnostics.Length |> shouldEqual 2 - let infoDiagnostics = - wholeProjectResults.Diagnostics - |> Array.filter (fun d -> d.Severity = FSharpDiagnosticSeverity.Info) - infoDiagnostics.Length |> shouldEqual 2 + wholeProjectResults.Diagnostics.Length |> shouldEqual 0 From 1eaf5d3af8a6b7b2b3f04d41e3f90b3746abe18b Mon Sep 17 00:00:00 2001 From: dawe Date: Mon, 12 Feb 2024 15:30:59 +0100 Subject: [PATCH 12/12] adjust quotation test, too. --- .../ConstraintSolver/ObjInference.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/ObjInference.fs b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/ObjInference.fs index a4971b2fadb..d12a462f384 100644 --- a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/ObjInference.fs +++ b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/ObjInference.fs @@ -111,13 +111,13 @@ let f () = x = x |> ignore""" // measure is inferred as 1, but that's not covere [] [] let ``Warn also inside quotations of acceptable code``(expr: string, line1: int, col1: int, line2: int, col2: int) = - sprintf "<@ %s @> |> ignore" expr + sprintf "module M\n<@ %s @> |> ignore" expr |> FSharp |> withWarnOn 3559 |> withLangVersion80 - |> typecheck + |> compile |> shouldFail - |> withSingleDiagnostic (Information 3559, Line line1, Col (col1 + 3), Line line2, Col (col2 + 3), message) + |> withSingleDiagnostic (Warning 3559, Line (line1 + 1), Col (col1 + 3), Line (line2 + 1), Col (col2 + 3), message) [] []