diff --git a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md index c4750e59e1f..ffd9a021cda 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md @@ -47,6 +47,7 @@ * Fix signature generation: SRTP constraints use postfix syntax that fails conformance, now uses explicit type param declarations. ([Issue #19594](https://github.com/dotnet/fsharp/issues/19594), [PR #19609](https://github.com/dotnet/fsharp/pull/19609)) * Fix signature generation: type params with special characters missing backtick escaping. ([Issue #19595](https://github.com/dotnet/fsharp/issues/19595), [PR #19609](https://github.com/dotnet/fsharp/pull/19609)) * Fix internal error when using custom attribute with `[]` value type parameter and no `[]`. ([Issue #8353](https://github.com/dotnet/fsharp/issues/8353), [PR #19484](https://github.com/dotnet/fsharp/pull/19484)) +* Fix parallel compilation of scripts ([PR #19649](https://github.com/dotnet/fsharp/pull/19649)) ### Added diff --git a/src/Compiler/Driver/GraphChecking/DependencyResolution.fs b/src/Compiler/Driver/GraphChecking/DependencyResolution.fs index fd2e0e2ffc9..388a8bdd929 100644 --- a/src/Compiler/Driver/GraphChecking/DependencyResolution.fs +++ b/src/Compiler/Driver/GraphChecking/DependencyResolution.fs @@ -254,31 +254,10 @@ let mkGraph (filePairs: FilePairMap) (files: FileInProject array) : Graph Array.tryFindIndexBack (fun f -> f.IsScript) - |> Option.map (fun idx -> idx + 1) - |> Option.defaultValue 0 - - let sequentialPartForScriptCompilation = - files - |> Array.take scriptCompilationLength - |> Array.map (fun file -> - file.Idx, - [| - if file.Idx > 0 then - file.Idx - 1 - |]) - - let normalPart = + let graph = files - |> Array.skip scriptCompilationLength |> Array.Parallel.map (fun file -> file.Idx, findDependencies file) - - let graph = - Array.append sequentialPartForScriptCompilation normalPart |> readOnlyDict + |> readOnlyDict let trie = trie |> Array.last |> snd diff --git a/src/Compiler/Driver/GraphChecking/TrieMapping.fs b/src/Compiler/Driver/GraphChecking/TrieMapping.fs index e8b027d8d5b..97170f1e499 100644 --- a/src/Compiler/Driver/GraphChecking/TrieMapping.fs +++ b/src/Compiler/Driver/GraphChecking/TrieMapping.fs @@ -158,13 +158,7 @@ let processSynModuleOrNamespace<'Decl> mkSingletonDict name { Current = current; Children = node } |> continuation) tail - if kind = SynModuleOrNamespaceKind.AnonModule then - // We collect the child nodes from the decls - decls - |> List.choose (mkTrieForDeclaration idx) - |> mkImmutableDictFromKeyValuePairs - else - visit id name + visit id name { Current = Root(ImmutableHashSet.empty ()) diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs index 2d73ff13130..1a15cdfe8a5 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs @@ -1105,7 +1105,7 @@ module LibB let append s i = s + string i """ - (set [| 0 |]) + Set.empty sourceFile "Run.fsx" """ @@ -1122,7 +1122,7 @@ module ScriptModule = let a = inc 41 append s a """ - (set [| 1 |]) + (set [| 0; 1 |]) sourceFile "Independent.fs" """ @@ -1150,6 +1150,24 @@ let value = Script.ScriptModule.compute "hi" """ (set [| 2 |]) ] + scenario + "Loaded script referenced by full path without open" + [ + sourceFile + "A.fsx" + """ +let value = 41 +""" + Set.empty + sourceFile + "B.fsx" + """ +#load "A.fsx" + +let result = A.value + 1 +""" + (set [| 0 |]) + ] scenario "Sub-namespace opens parent namespace with types and modules" [ diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/TrieMappingTests.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/TrieMappingTests.fs index 02b8d998fe1..1ff1923bd21 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/TrieMappingTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/TrieMappingTests.fs @@ -490,6 +490,9 @@ module ``module`` = } |] + // Dive into the anonymous module created for Program.fs + let trie = trie.Children["Program"] + Assert.Equal(1, trie.Children.Count) Assert.True(trie.Children.ContainsKey("module"))