Skip to content

Allow merging of Namespace and Module in TrieMapping #16070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Compiler/Driver/GraphChecking/TrieMapping.fs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ let mergeTrieNodes (defaultChildSize: int) (tries: TrieNode array) =
TrieNodeInfo.Namespace (filesThatExposeTypes = otherFiles; filesDefiningNamespaceWithoutTypes = otherFilesWithoutTypes) ->
currentFilesThatExposeTypes.UnionWith otherFiles
currentFilesWithoutTypes.UnionWith otherFilesWithoutTypes
// Edge case scenario detected in https://github.com/dotnet/fsharp/issues/15985
| TrieNodeInfo.Namespace (filesThatExposeTypes = currentFilesThatExposeTypes), TrieNodeInfo.Module (_name, file) ->
// Keep the namespace (as it can still have nested children).
currentFilesThatExposeTypes.Add file |> ignore
| TrieNodeInfo.Module (_name, file), TrieNodeInfo.Namespace (filesThatExposeTypes = currentFilesThatExposeTypes) ->
currentFilesThatExposeTypes.Add file |> ignore
// Replace the module in favour of the namespace (which can hold nested children).
root.Children[ k ] <- v
| _ -> ()

for kv in v.Children do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,4 +688,66 @@ module ColdTasks =
"""
(set [| 0; 2 |])
]
scenario
"ModuleSuffix clash"
[
sourceFile
"A.fs"
"""
namespace F.General
"""
Set.empty
sourceFile
"B.fs"
"""
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module F

let br () = ()
"""
Set.empty

sourceFile
"C.fs"
"""
module S

[<EntryPoint>]
let main _ =
F.br ()
0
"""
(set [| 1 |])
]
scenario
"ModuleSuffix clash, module before namespace"
[
sourceFile
"A.fs"
"""
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module F

let br () = ()
"""
Set.empty
sourceFile
"B.fs"
"""
namespace F.General
"""
Set.empty

sourceFile
"C.fs"
"""
module S

[<EntryPoint>]
let main _ =
F.br ()
0
"""
(set [| 0 |])
]
]