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 5d4bd0fe6ac..4f3ac2996a5 100644
--- a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
+++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
@@ -92,6 +92,7 @@
* Symbols: add ObsoleteDiagnosticInfo ([PR #19359](https://github.com/dotnet/fsharp/pull/19359))
* FCS: add FSharpCheckFileResults.HasErrors ([PR #19892](https://github.com/dotnet/fsharp/pull/19892))
* Add `#version;;` directive to F# Interactive to display version and environment information. ([Issue #13307](https://github.com/dotnet/fsharp/issues/13307), [PR #19332](https://github.com/dotnet/fsharp/pull/19332))
+* Add diagnostic FS3889 when a namespace and a type have the same fully-qualified name in the same assembly, replacing the misleading FS0247 "namespace and a module" error. ([Issue #17827](https://github.com/dotnet/fsharp/issues/17827), [PR #19802](https://github.com/dotnet/fsharp/pull/19802))
* Debug: rework for expressions stepping ([PR #19894](https://github.com/dotnet/fsharp/pull/19894))
* Debug: rework conditional erasure, fix stepping over literals ([PR #19897](https://github.com/dotnet/fsharp/pull/19897))
* Debug: fix if and match condition sequence points ([PR #19932](https://github.com/dotnet/fsharp/pull/19932))
diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt
index dc27f32bae9..d29b5d3dde7 100644
--- a/src/Compiler/FSComp.txt
+++ b/src/Compiler/FSComp.txt
@@ -1819,5 +1819,6 @@ featurePreprocessorElif,"#elif preprocessor directive"
3886,tcListLiteralWithSingleTupleElement,"This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements?"
3887,ilCustomAttrInvalidArrayElemType,"The type '%s' is not a valid custom attribute argument type. Custom attribute arrays must have elements of primitive types, enums, string, System.Type, or System.Object."
3888,implAttributeMissingFromSignature,"The attribute '%s' is present on '%s' in the implementation but not in the signature, which takes precedence for tooling and consumers. Add the attribute to the signature, to ensure the attribute is not ignored by the compiler."
+3889,tastNamespaceAndTypeWithSameNameInAssembly,"The namespace '%s' clashes with the type '%s'."
featureExceptionFieldSerializationSupport,"emit GetObjectData and field-restoring deserialization constructor for exception types"
featureErrorOnMissingSignatureAttribute,"error (rather than warning) when an enforced compiler-semantic attribute is present in the .fs but missing from the .fsi"
diff --git a/src/Compiler/TypedTree/TypedTreeOps.Remapping.fs b/src/Compiler/TypedTree/TypedTreeOps.Remapping.fs
index 7401ed40b14..f9927fec68f 100644
--- a/src/Compiler/TypedTree/TypedTreeOps.Remapping.fs
+++ b/src/Compiler/TypedTree/TypedTreeOps.Remapping.fs
@@ -622,8 +622,11 @@ module internal SignatureOps =
match entity1.IsNamespace, entity2.IsNamespace, entity1.IsModule, entity2.IsModule with
| true, true, _, _ -> ()
+ | true, _, _, true
+ | _, true, true, _ -> errorR (Error(FSComp.SR.tastNamespaceAndModuleWithSameNameInAssembly (textOfPath path2), entity2.Range))
| true, _, _, _
- | _, true, _, _ -> errorR (Error(FSComp.SR.tastNamespaceAndModuleWithSameNameInAssembly (textOfPath path2), entity2.Range))
+ | _, true, _, _ ->
+ errorR (Error(FSComp.SR.tastNamespaceAndTypeWithSameNameInAssembly (textOfPath path2, entity2.LogicalName), entity2.Range))
| false, false, false, false ->
errorR (Error(FSComp.SR.tastDuplicateTypeDefinitionInAssembly (entity2.LogicalName, textOfPath path), entity2.Range))
| false, false, true, true -> errorR (Error(FSComp.SR.tastTwoModulesWithSameNameInAssembly (textOfPath path2), entity2.Range))
diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf
index 84e5e3cc50c..3ea52c5b169 100644
--- a/src/Compiler/xlf/FSComp.txt.cs.xlf
+++ b/src/Compiler/xlf/FSComp.txt.cs.xlf
@@ -1362,6 +1362,11 @@
(Navržený název)
+
+ The namespace '{0}' clashes with the type '{1}'.
+ The namespace '{0}' clashes with the type '{1}'.
+
+ Access modifiers cannot be applied to an SRTP constraint.Access modifiers cannot be applied to an SRTP constraint.
diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf
index d6edecb4def..f9fc62909ef 100644
--- a/src/Compiler/xlf/FSComp.txt.de.xlf
+++ b/src/Compiler/xlf/FSComp.txt.de.xlf
@@ -1362,6 +1362,11 @@
(Empfohlener Name)
+
+ The namespace '{0}' clashes with the type '{1}'.
+ The namespace '{0}' clashes with the type '{1}'.
+
+ Access modifiers cannot be applied to an SRTP constraint.Access modifiers cannot be applied to an SRTP constraint.
diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf
index 46573e801f1..eca7c688eed 100644
--- a/src/Compiler/xlf/FSComp.txt.es.xlf
+++ b/src/Compiler/xlf/FSComp.txt.es.xlf
@@ -1362,6 +1362,11 @@
(Nombre sugerido)
+
+ The namespace '{0}' clashes with the type '{1}'.
+ The namespace '{0}' clashes with the type '{1}'.
+
+ Access modifiers cannot be applied to an SRTP constraint.Access modifiers cannot be applied to an SRTP constraint.
diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf
index 1acfc469b5b..0922cee5acd 100644
--- a/src/Compiler/xlf/FSComp.txt.fr.xlf
+++ b/src/Compiler/xlf/FSComp.txt.fr.xlf
@@ -1362,6 +1362,11 @@
(Nom suggéré)
+
+ The namespace '{0}' clashes with the type '{1}'.
+ The namespace '{0}' clashes with the type '{1}'.
+
+ Access modifiers cannot be applied to an SRTP constraint.Access modifiers cannot be applied to an SRTP constraint.
diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf
index deaca46fad0..d39f0a33a85 100644
--- a/src/Compiler/xlf/FSComp.txt.it.xlf
+++ b/src/Compiler/xlf/FSComp.txt.it.xlf
@@ -1362,6 +1362,11 @@
(Nome consigliato)
+
+ The namespace '{0}' clashes with the type '{1}'.
+ The namespace '{0}' clashes with the type '{1}'.
+
+ Access modifiers cannot be applied to an SRTP constraint.Access modifiers cannot be applied to an SRTP constraint.
diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf
index 10029fab134..6f4969e8148 100644
--- a/src/Compiler/xlf/FSComp.txt.ja.xlf
+++ b/src/Compiler/xlf/FSComp.txt.ja.xlf
@@ -1362,6 +1362,11 @@
(推奨される名前)
+
+ The namespace '{0}' clashes with the type '{1}'.
+ The namespace '{0}' clashes with the type '{1}'.
+
+ Access modifiers cannot be applied to an SRTP constraint.Access modifiers cannot be applied to an SRTP constraint.
diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf
index 1d7a19af957..fb488a6c240 100644
--- a/src/Compiler/xlf/FSComp.txt.ko.xlf
+++ b/src/Compiler/xlf/FSComp.txt.ko.xlf
@@ -1362,6 +1362,11 @@
(제안된 이름)
+
+ The namespace '{0}' clashes with the type '{1}'.
+ The namespace '{0}' clashes with the type '{1}'.
+
+ Access modifiers cannot be applied to an SRTP constraint.Access modifiers cannot be applied to an SRTP constraint.
diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf
index 170e6e37718..2720c59fc22 100644
--- a/src/Compiler/xlf/FSComp.txt.pl.xlf
+++ b/src/Compiler/xlf/FSComp.txt.pl.xlf
@@ -1362,6 +1362,11 @@
(Sugerowana nazwa)
+
+ The namespace '{0}' clashes with the type '{1}'.
+ The namespace '{0}' clashes with the type '{1}'.
+
+ Access modifiers cannot be applied to an SRTP constraint.Access modifiers cannot be applied to an SRTP constraint.
diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf
index 87ef255a7e8..8fc5566545f 100644
--- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf
+++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf
@@ -1362,6 +1362,11 @@
(Nome sugerido)
+
+ The namespace '{0}' clashes with the type '{1}'.
+ The namespace '{0}' clashes with the type '{1}'.
+
+ Access modifiers cannot be applied to an SRTP constraint.Access modifiers cannot be applied to an SRTP constraint.
diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf
index 57f29e98517..16eb9766b81 100644
--- a/src/Compiler/xlf/FSComp.txt.ru.xlf
+++ b/src/Compiler/xlf/FSComp.txt.ru.xlf
@@ -1362,6 +1362,11 @@
(предложенное имя)
+
+ The namespace '{0}' clashes with the type '{1}'.
+ The namespace '{0}' clashes with the type '{1}'.
+
+ Access modifiers cannot be applied to an SRTP constraint.Access modifiers cannot be applied to an SRTP constraint.
diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf
index 08753e47a27..da5fd475a81 100644
--- a/src/Compiler/xlf/FSComp.txt.tr.xlf
+++ b/src/Compiler/xlf/FSComp.txt.tr.xlf
@@ -1362,6 +1362,11 @@
(Önerilen ad)
+
+ The namespace '{0}' clashes with the type '{1}'.
+ The namespace '{0}' clashes with the type '{1}'.
+
+ Access modifiers cannot be applied to an SRTP constraint.Access modifiers cannot be applied to an SRTP constraint.
diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
index e117ab0ec5d..c43aa519603 100644
--- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
+++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
@@ -1362,6 +1362,11 @@
(建议名称)
+
+ The namespace '{0}' clashes with the type '{1}'.
+ The namespace '{0}' clashes with the type '{1}'.
+
+ Access modifiers cannot be applied to an SRTP constraint.Access modifiers cannot be applied to an SRTP constraint.
diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
index 31c5596a098..d287b294184 100644
--- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
+++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
@@ -1362,6 +1362,11 @@
(建議的名稱)
+
+ The namespace '{0}' clashes with the type '{1}'.
+ The namespace '{0}' clashes with the type '{1}'.
+
+ Access modifiers cannot be applied to an SRTP constraint.Access modifiers cannot be applied to an SRTP constraint.
diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NamespaceTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NamespaceTests.fs
index f989220189e..f1a5663e8d8 100644
--- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NamespaceTests.fs
+++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NamespaceTests.fs
@@ -80,4 +80,33 @@ do printfn "test"
|> shouldFail
|> withDiagnostics [
(Error 201, Line 4, Col 1, Line 4, Col 18, "Namespaces cannot contain values. Consider using a module to hold your value declarations.")
- ]
\ No newline at end of file
+ ]
+
+[]
+let ``Namespace-type collision says type not module (FS3889)`` () =
+ let source1 = """namespace Ns
+type T = { Field: int }
+"""
+ let source2 = "namespace Ns.T"
+ FSharp source1
+ |> withAdditionalSourceFile (FsSourceWithFileName "second.fs" source2)
+ |> compile
+ |> shouldFail
+ |> withErrorCode 3889
+ |> withDiagnosticMessageMatches "type"
+ |> ignore
+
+[]
+let ``Namespace-module collision still says module (FS0247)`` () =
+ let source1 = """namespace Ns
+module M =
+ let x = 1
+"""
+ let source2 = "namespace Ns.M"
+ FSharp source1
+ |> withAdditionalSourceFile (FsSourceWithFileName "second.fs" source2)
+ |> compile
+ |> shouldFail
+ |> withErrorCode 0247
+ |> withDiagnosticMessageMatches "namespace and a module"
+ |> ignore
\ No newline at end of file