diff --git a/src/Compiler/TypedTree/TypedTree.fs b/src/Compiler/TypedTree/TypedTree.fs index 39d090939167a633110670cd362358d36703e99f..b3fcdd6c7d532d00bbd33ef40236a6da0a67cae3 100644 --- a/src/Compiler/TypedTree/TypedTree.fs +++ b/src/Compiler/TypedTree/TypedTree.fs @@ -475,6 +475,7 @@ exception UndefinedName of exception InternalUndefinedItemRef of (string * string * string -> int * string) * string * string * string +[] type ModuleOrNamespaceKind = /// Indicates that a module is compiled to a class with the "Module" suffix added. @@ -488,6 +489,22 @@ type ModuleOrNamespaceKind = /// Indicates that the sourcecode had a namespace. /// If false, this namespace was implicitly constructed during type checking. isExplicit: bool + + override this.Equals other = + match other with + | :? ModuleOrNamespaceKind as kind -> + match this, kind with + | FSharpModuleWithSuffix, FSharpModuleWithSuffix + | ModuleOrType, ModuleOrType + | Namespace _, Namespace _ -> true + | _ -> false + | _ -> false + + override this.GetHashCode () = + match this with + | FSharpModuleWithSuffix -> 0 + | ModuleOrType -> 1 + | Namespace _ -> 2 /// A public path records where a construct lives within the global namespace /// of a CCU. diff --git a/src/Compiler/TypedTree/TypedTree.fsi b/src/Compiler/TypedTree/TypedTree.fsi index 2487daf351700aba3a8ea4796a2be17a1d355db7..d55e5e407067ab0777380c7cd08654b75d94c199 100644 --- a/src/Compiler/TypedTree/TypedTree.fsi +++ b/src/Compiler/TypedTree/TypedTree.fsi @@ -294,6 +294,7 @@ exception UndefinedName of depth: int * error: (string -> string) * id: Ident * exception InternalUndefinedItemRef of (string * string * string -> int * string) * string * string * string +[] type ModuleOrNamespaceKind = /// Indicates that a module is compiled to a class with the "Module" suffix added. diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicTypeAndModuleDefinitions/ModuleDefinitions/ModuleDefinitions.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicTypeAndModuleDefinitions/ModuleDefinitions/ModuleDefinitions.fs index af33f5c0f1e5526c62e12f4e3f86488b35c71d62..65d694c96474ce6c1526be3f5e34d3a6e7d1cc4e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicTypeAndModuleDefinitions/ModuleDefinitions/ModuleDefinitions.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicTypeAndModuleDefinitions/ModuleDefinitions/ModuleDefinitions.fs @@ -318,3 +318,36 @@ module ModuleDefinitions = |> withReferences [libFoo2; libFoo1] |> verifyCompileAndRun |> shouldSucceed + + [] + let ``Regression: compilation error with private types in namespace used in a different file`` () = + let types = + """ + namespace FsErrorRepro + + type private Blah = { Number: int } + """ + let example = + """ + [] + module FsErrorRepro.Example + + let dummy (blahNum: int) = + let blah : Blah = { Number = blahNum } + printf $"%i{blah.Number}" + """ + let program = + """ + module FsErrorRepro.Main + + [] + let main _ = + Example.dummy 15 + 0 + """ + + FSharp types + |> withAdditionalSourceFiles [SourceCodeFileKind.Create("example.fs", example) + SourceCodeFileKind.Create("program.fs", program)] + |> compile + |> shouldSucceed