From abf70a6e1687a0ff3d940744faa885d76f39a737 Mon Sep 17 00:00:00 2001 From: ncave <777696+ncave@users.noreply.github.com> Date: Sun, 15 Oct 2023 14:27:59 -0700 Subject: [PATCH] Fixed merge --- .vscode/launch.json | 2 +- buildtools/AssemblyCheck/AssemblyCheck.fsproj | 2 -- buildtools/buildtools.targets | 4 ++-- buildtools/fslex/fslex.fsproj | 2 -- buildtools/fsyacc/fsyacc.fsproj | 2 -- fcs/fcs-test/fcs-test.fsproj | 8 +++---- fcs/service_slim.fs | 22 +++++++++++++------ src/Compiler/Service/service.fs | 2 ++ src/Compiler/Service/service.fsi | 2 +- 9 files changed, 25 insertions(+), 21 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index d56023b999f..07df7ab96ae 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -92,7 +92,7 @@ "name": "FCS Test", "type": "coreclr", "request": "launch", - "program": "${workspaceFolder}/artifacts/bin/fcs-test/Debug/net7.0/fcs-test.dll", + "program": "${workspaceFolder}/artifacts/bin/fcs-test/Debug/net8.0/fcs-test.dll", "args": [], "cwd": "${workspaceFolder}/fcs/fcs-test", "console": "internalConsole", diff --git a/buildtools/AssemblyCheck/AssemblyCheck.fsproj b/buildtools/AssemblyCheck/AssemblyCheck.fsproj index bc9584cf701..46ffb722cd4 100644 --- a/buildtools/AssemblyCheck/AssemblyCheck.fsproj +++ b/buildtools/AssemblyCheck/AssemblyCheck.fsproj @@ -3,8 +3,6 @@ Exe net8.0 - net6.0 - net7.0 true false diff --git a/buildtools/buildtools.targets b/buildtools/buildtools.targets index 3b2fa489c66..b4160b714f2 100644 --- a/buildtools/buildtools.targets +++ b/buildtools/buildtools.targets @@ -20,7 +20,7 @@ BeforeTargets="CoreCompile"> - $(ArtifactsDir)\bin\fslex\Release\net7.0\fslex.dll + $(ArtifactsDir)\bin\fslex\Release\net8.0\fslex.dll @@ -44,7 +44,7 @@ BeforeTargets="CoreCompile"> - $(ArtifactsDir)\bin\fsyacc\Release\net7.0\fsyacc.dll + $(ArtifactsDir)\bin\fsyacc\Release\net8.0\fsyacc.dll diff --git a/buildtools/fslex/fslex.fsproj b/buildtools/fslex/fslex.fsproj index 72d3d7d420c..674dde7c759 100644 --- a/buildtools/fslex/fslex.fsproj +++ b/buildtools/fslex/fslex.fsproj @@ -3,8 +3,6 @@ Exe net8.0 - net7.0 - INTERNALIZED_FSLEXYACC_RUNTIME;$(DefineConstants) true false LatestMajor diff --git a/buildtools/fsyacc/fsyacc.fsproj b/buildtools/fsyacc/fsyacc.fsproj index 3bc4c7c5203..fc072b7cf02 100644 --- a/buildtools/fsyacc/fsyacc.fsproj +++ b/buildtools/fsyacc/fsyacc.fsproj @@ -3,8 +3,6 @@ Exe net8.0 - net7.0 - INTERNALIZED_FSLEXYACC_RUNTIME;$(DefineConstants) true false LatestMajor diff --git a/fcs/fcs-test/fcs-test.fsproj b/fcs/fcs-test/fcs-test.fsproj index 3a8c1940791..fd951e954ea 100644 --- a/fcs/fcs-test/fcs-test.fsproj +++ b/fcs/fcs-test/fcs-test.fsproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 true @@ -19,9 +19,9 @@ - - - + + + diff --git a/fcs/service_slim.fs b/fcs/service_slim.fs index f7c5b9b2343..7cccc9f4168 100644 --- a/fcs/service_slim.fs +++ b/fcs/service_slim.fs @@ -188,12 +188,14 @@ module internal ParseAndCheck = // restore all cached typecheck entries above file cachedAbove |> Array.iter (fun (key, value) -> compilerState.checkCache.TryAdd(key, value) |> ignore) - let ParseFile (fileName: string, sourceHash: int, source: Lazy, parsingOptions: FSharpParsingOptions, compilerState) = + let ParseFile (fileName: string, sourceHash: int, source: Lazy, parsingOptions: FSharpParsingOptions, compilerState, ct) = let parseCacheKey = fileName, sourceHash compilerState.parseCache.GetOrAdd(parseCacheKey, fun _ -> ClearStaleCache(fileName, parsingOptions, compilerState) let sourceText = SourceText.ofString source.Value - let parseErrors, parseTreeOpt, anyErrors = ParseAndCheckFile.parseFile (sourceText, fileName, parsingOptions, userOpName, suggestNamesForErrors, captureIdentifiersWhenParsing) + let flatErrors = compilerState.tcConfig.flatErrors + let parseErrors, parseTreeOpt, anyErrors = + ParseAndCheckFile.parseFile (sourceText, fileName, parsingOptions, userOpName, suggestNamesForErrors, flatErrors, captureIdentifiersWhenParsing, ct) let dependencyFiles = [||] // interactions have no dependencies FSharpParseFileResults (parseErrors, parseTreeOpt, anyErrors, dependencyFiles) ) @@ -213,7 +215,9 @@ module internal ParseAndCheck = |> Cancellable.runWithoutCancellation let fileName = parseResults.FileName - let tcErrors = DiagnosticHelpers.CreateDiagnostics (diagnosticsOptions, false, fileName, (capturingLogger.GetDiagnostics()), suggestNamesForErrors) + let flatErrors = compilerState.tcConfig.flatErrors + let parseDiagnostics = capturingLogger.GetDiagnostics() + let tcErrors = DiagnosticHelpers.CreateDiagnostics (diagnosticsOptions, false, fileName, parseDiagnostics, suggestNamesForErrors, flatErrors, None) (tcResult, tcErrors), (tcState, moduleNamesDict) let CheckFile (projectFileName: string, parseResults: FSharpParseFileResults, tcState: TcState, moduleNamesDict: ModuleNamesDict, compilerState) = @@ -295,17 +299,19 @@ type InteractiveChecker internal (compilerStateCache) = /// Compile project to file. If project has already been type checked, /// check results will be taken from the cache. member _.Compile(fileNames: string[], sourceReader: string -> int * Lazy, outFile: string) = async { + let! ct = Async.CancellationToken let! compilerState = compilerStateCache.Get() let parsingOptions = FSharpParsingOptions.FromTcConfig(compilerState.tcConfig, fileNames, false) let parseResults = fileNames |> Array.map (fun fileName -> let sourceHash, source = sourceReader fileName - ParseFile(fileName, sourceHash, source, parsingOptions, compilerState)) + ParseFile(fileName, sourceHash, source, parsingOptions, compilerState, ct)) let (tcState, topAttrs, tcImplFiles, _tcEnvAtEnd, _moduleNamesDict, _tcErrors) = TypeCheckClosedInputSet (parseResults, compilerState.tcInitialState, compilerState, None) let ctok = CompilationThreadToken() - let errors, diagnosticsLogger, _loggerProvider = CompileHelpers.mkCompilationDiagnosticsHandlers() + let flatErrors = compilerState.tcConfig.flatErrors + let errors, diagnosticsLogger, _loggerProvider = CompileHelpers.mkCompilationDiagnosticsHandlers(flatErrors) let exitCode = CompileHelpers.tryCompile diagnosticsLogger (fun exiter -> CompileFromTypedAst (ctok, compilerState.tcGlobals, compilerState.tcImports, tcState.Ccu, @@ -319,6 +325,7 @@ type InteractiveChecker internal (compilerStateCache) = /// Already parsed files will be cached so subsequent compilations will be faster. member _.ParseAndCheckProject (projectFileName: string, fileNames: string[], sourceReader: string -> int * Lazy, ?lastFile: string, ?subscriber: FSharpImplementationFileContents -> unit) = async { + let! ct = Async.CancellationToken let! compilerState = compilerStateCache.Get() // parse files let parsingOptions = FSharpParsingOptions.FromTcConfig(compilerState.tcConfig, fileNames, false) @@ -332,7 +339,7 @@ type InteractiveChecker internal (compilerStateCache) = let parseFile fileName = let sourceHash, source = sourceReader fileName - ParseFile(fileName, sourceHash, source, parsingOptions, compilerState) + ParseFile(fileName, sourceHash, source, parsingOptions, compilerState, ct) // Don't parallelize if we have cached files, as it would create issues with invalidation if compilerState.parseCache.Count = 0 then @@ -358,6 +365,7 @@ type InteractiveChecker internal (compilerStateCache) = /// up to and including the file requested. Returns parse and typecheck results containing /// name resolutions and symbol uses for the file requested only, so intellisense etc. works. member _.ParseAndCheckFileInProject (projectFileName: string, fileNames: string[], sourceReader: string -> int * Lazy, fileName: string) = async { + let! ct = Async.CancellationToken let! compilerState = compilerStateCache.Get() // get files before file @@ -368,7 +376,7 @@ type InteractiveChecker internal (compilerStateCache) = let parsingOptions = FSharpParsingOptions.FromTcConfig(compilerState.tcConfig, fileNames, false) let parseFile fileName = let sourceHash, source = sourceReader fileName - ParseFile (fileName, sourceHash, source, parsingOptions, compilerState) + ParseFile (fileName, sourceHash, source, parsingOptions, compilerState, ct) let parseResults = fileNamesBeforeFile |> Array.map parseFile // type check files before file diff --git a/src/Compiler/Service/service.fs b/src/Compiler/Service/service.fs index 615b7458691..feb8b0405dc 100644 --- a/src/Compiler/Service/service.fs +++ b/src/Compiler/Service/service.fs @@ -157,6 +157,7 @@ module CompileHelpers = diagnostics.ToArray(), result +#if !FABLE_CLI let setOutputStreams execute = // Set the output streams, if requested match execute with @@ -164,6 +165,7 @@ module CompileHelpers = Console.SetOut writer Console.SetError error | None -> () +#endif type SourceTextHash = int64 type CacheStamp = int64 diff --git a/src/Compiler/Service/service.fsi b/src/Compiler/Service/service.fsi index dc903cdedb7..8686941df22 100644 --- a/src/Compiler/Service/service.fsi +++ b/src/Compiler/Service/service.fsi @@ -19,7 +19,7 @@ open FSharp.Compiler.DiagnosticsLogger open FSharp.Compiler.Driver module internal CompileHelpers = - val mkCompilationDiagnosticsHandlers: unit -> ResizeArray * DiagnosticsLogger * IDiagnosticsLoggerProvider + val mkCompilationDiagnosticsHandlers: bool -> ResizeArray * DiagnosticsLogger * IDiagnosticsLoggerProvider val tryCompile: DiagnosticsLogger -> (StopProcessingExiter -> unit) -> int []