From c35152fdf1cdaa2b1245672d8c24148905ed4514 Mon Sep 17 00:00:00 2001 From: Jakub Majocha <1760221+majocha@users.noreply.github.com> Date: Mon, 4 May 2026 11:33:14 +0200 Subject: [PATCH 1/5] add scenario --- .../TypeChecks/Graph/Scenarios.fs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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" [ From 5e21f0dc9219d5b0273df37f5d56b789af178911 Mon Sep 17 00:00:00 2001 From: Jakub Majocha <1760221+majocha@users.noreply.github.com> Date: Mon, 4 May 2026 11:33:45 +0200 Subject: [PATCH 2/5] remove script extra handling --- .../GraphChecking/DependencyResolution.fs | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) 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 From fb404991b900f0884160baf7867be6c593ff0b78 Mon Sep 17 00:00:00 2001 From: Jakub Majocha <1760221+majocha@users.noreply.github.com> Date: Mon, 4 May 2026 11:34:27 +0200 Subject: [PATCH 3/5] include AnonModules --- src/Compiler/Driver/GraphChecking/TrieMapping.fs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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 ()) From ac55adafb0aa5c4979e99f9cf208bb7d34699dda Mon Sep 17 00:00:00 2001 From: Jakub Majocha <1760221+majocha@users.noreply.github.com> Date: Mon, 4 May 2026 12:40:38 +0200 Subject: [PATCH 4/5] fix test --- .../TypeChecks/Graph/TrieMappingTests.fs | 3 +++ 1 file changed, 3 insertions(+) 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")) From fb265e88e73b58cee3944e2eade2ea52e408c4b6 Mon Sep 17 00:00:00 2001 From: Jakub Majocha <1760221+majocha@users.noreply.github.com> Date: Mon, 4 May 2026 17:21:17 +0200 Subject: [PATCH 5/5] release notes --- docs/release-notes/.FSharp.Compiler.Service/11.0.100.md | 1 + 1 file changed, 1 insertion(+) 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 78309ef44f5..babe1690b01 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md @@ -46,6 +46,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