From 7a41d857a41ceccb0241e4fb6b0180edf3eee823 Mon Sep 17 00:00:00 2001 From: Jakub Majocha Date: Fri, 23 Feb 2024 10:08:40 +0100 Subject: [PATCH 1/2] fix some inconsistencies --- src/Compiler/Driver/ParseAndCheckInputs.fs | 30 +++++++++++++--------- src/Compiler/Driver/fsc.fs | 4 +-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/Compiler/Driver/ParseAndCheckInputs.fs b/src/Compiler/Driver/ParseAndCheckInputs.fs index 5a23c95ca7b..bdb0d1defd6 100644 --- a/src/Compiler/Driver/ParseAndCheckInputs.fs +++ b/src/Compiler/Driver/ParseAndCheckInputs.fs @@ -1389,15 +1389,17 @@ let DiagnosticsLoggerForInput (tcConfig: TcConfig, input: ParsedInput, oldLogger /// Typecheck a single file (or interactive entry into F# Interactive) let CheckOneInputEntry (ctok, checkForErrors, tcConfig: TcConfig, tcImports, tcGlobals, prefixPathOpt) tcState input = - // Equip loggers to locally filter w.r.t. scope pragmas in each input - use _ = - UseTransformedDiagnosticsLogger(fun oldLogger -> DiagnosticsLoggerForInput(tcConfig, input, oldLogger)) + cancellable { + // Equip loggers to locally filter w.r.t. scope pragmas in each input + use _ = + UseTransformedDiagnosticsLogger(fun oldLogger -> DiagnosticsLoggerForInput(tcConfig, input, oldLogger)) - use _ = UseBuildPhase BuildPhase.TypeCheck + use _ = UseBuildPhase BuildPhase.TypeCheck - RequireCompilationThread ctok + RequireCompilationThread ctok - CheckOneInput(checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, TcResultsSink.NoSink, tcState, input) + return! CheckOneInput(checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, TcResultsSink.NoSink, tcState, input) + } |> Cancellable.runWithoutCancellation /// Finish checking multiple files (or one interactive entry into F# Interactive) @@ -1859,14 +1861,18 @@ let CheckMultipleInputsUsingGraphMode ((input, logger): ParsedInput * DiagnosticsLogger) ((currentTcState, _currentPriorErrors): State) : Finisher = - use _ = UseDiagnosticsLogger logger - let checkForErrors2 () = priorErrors || (logger.ErrorCount > 0) - let tcSink = TcResultsSink.NoSink let (Finisher(finisher = finisher)) = - CheckOneInputWithCallback - node - (checkForErrors2, tcConfig, tcImports, tcGlobals, prefixPathOpt, tcSink, currentTcState, input, false) + cancellable { + use _ = UseDiagnosticsLogger logger + let checkForErrors2 () = priorErrors || (logger.ErrorCount > 0) + let tcSink = TcResultsSink.NoSink + + return! + CheckOneInputWithCallback + node + (checkForErrors2, tcConfig, tcImports, tcGlobals, prefixPathOpt, tcSink, currentTcState, input, false) + } |> Cancellable.runWithoutCancellation Finisher( diff --git a/src/Compiler/Driver/fsc.fs b/src/Compiler/Driver/fsc.fs index 014ed840222..fe3b369b3c7 100644 --- a/src/Compiler/Driver/fsc.fs +++ b/src/Compiler/Driver/fsc.fs @@ -525,7 +525,7 @@ let main1 // Now install a delayed logger to hold all errors from flags until after all flags have been parsed (for example, --vserrors) let delayForFlagsLogger = CapturingDiagnosticsLogger("DelayFlagsLogger") - let _holder = UseDiagnosticsLogger delayForFlagsLogger + SetThreadDiagnosticsLoggerNoUnwind delayForFlagsLogger // Share intern'd strings across all lexing/parsing let lexResourceManager = Lexhelp.LexResourceManager() @@ -596,7 +596,7 @@ let main1 let diagnosticsLogger = diagnosticsLoggerProvider.CreateLogger(tcConfigB, exiter) // Install the global error logger and never remove it. This logger does have all command-line flags considered. - let _holder = UseDiagnosticsLogger diagnosticsLogger + SetThreadDiagnosticsLoggerNoUnwind diagnosticsLogger // Forward all errors from flags delayForFlagsLogger.CommitDelayedDiagnostics diagnosticsLogger From 22e955a0b58d98aa0ddbecd43e3348787a7dd26a Mon Sep 17 00:00:00 2001 From: Jakub Majocha Date: Fri, 23 Feb 2024 12:11:15 +0100 Subject: [PATCH 2/2] we don't intend to dispose this ever --- src/Compiler/Driver/fsc.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Driver/fsc.fs b/src/Compiler/Driver/fsc.fs index fe3b369b3c7..3cebc51d10f 100644 --- a/src/Compiler/Driver/fsc.fs +++ b/src/Compiler/Driver/fsc.fs @@ -749,7 +749,7 @@ let main2 GetDiagnosticsLoggerFilteringByScopedPragmas(true, scopedPragmas, tcConfig.diagnosticsOptions, oldLogger) - let _holder = UseDiagnosticsLogger diagnosticsLogger + SetThreadDiagnosticsLoggerNoUnwind diagnosticsLogger // Try to find an AssemblyVersion attribute let assemVerFromAttrib =