Reputation: 769
This one always gets me, and I fail to understand the problem the F# compiler is having here.
I have two files for two modules.
A.fs:
module A
//rest of the module goes here
B.fs
module A.B
//rest of the module goes here
When I build this project, I get:
A.fs(1, 8): [FS0247] A namespace and a module named 'A' both occur in two parts of this assembly
Why? There is nothing else in the project, other than the Program.fs. Am I wrong to assume I can break down modules into multiple files to keep things under control, while using a namespace like naming scheme? (obviously the compiler thinks so).
I want to understand the problem the compiler is having here and why I'm presented an error that refers to namespaces, even though I have no namespace declarations in my code.
Upvotes: 6
Views: 718
Reputation: 769
Here is an answer to this question, just in case someone encounters the same error and googles their way here.
This bit from the modules documentation explains what is going on:
In the syntax for the top-level module declaration, the optional qualified-namespace is the sequence of nested namespace names that contains the module.
By declaring a module as A.B
I'm actually declaring a module B
in namespace A
as per the above description. So I'm ending up with a module named A
due to
module A
and a namespace A
due to module A.B
and the compiler is telling me that I now have both a module and a namespace named A
in this assembly.
I'll change this answer or un-accept it in case I'm wrong.
Upvotes: 10