You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
F# allows same module names if in different namespaces, but not same file names even if in different folders #3231
When having module name clashes, namespacing is important.
For example, you have two modules named "Foo" in the same F# assembly. If you place them under namespaces Bar.Foo and Baz.Foo, the compiler is happy.
However, normally developers try to mimic directory-file name structures to map exactly with namespace-type ones. In this case, the F# compiler is not helping, because placing two Foo.fs for the same project, even if in different directories Bar\Foo.fs and Baz\Foo.fs, it gives this error:
error FS0239: An implementation of the file or module 'Foo' has already been given
Repro steps
Have an F# project with 2 modules Foo: one namespaced Bar.Foo (BarFoo.fs) and the other Baz.Foo (BazFoo.fs).
F# compiler compiles the project succesfully.
Move BarFoo.fs to a subfolder Bar and rename the file to Foo.fs.
Move BazFoo.fs to a subfolder Baz and rename the file to Foo.fs.
Try to compile again.
Expected behavior
F# compiler should succeed.
Actual behavior
error FS0239: An implementation of the file or module 'Foo' has already been given
Known workarounds
Rename files to redundant names such as BarFoo.fs and BazFoo.fs (even if they're already in Bar and Baz directories).
@knocte It will be in the 15.3 update, and is in the process of being integrated into the Mono 5.x series (which already contain F# 4.1, but not this fix)
and the exchange-name/RestClient is what gives the error: An implementation of the file or module 'RestClient__2' has already been given.
But the base/RestClient.fs only defines type public IRestClient and type public AbstractRestClient`
Reacted by Severin Sverdvik, mfrischknecht and Alex P
Activity
forki commentedon Jun 21, 2017
Didn't we fix this already?
forki commentedon Jun 21, 2017
related #2772
knocte commentedon Jun 21, 2017
@forki I see the fix for that was merged in the 3rd of April. Did that change make it to the F#4.1 release?
dsyme commentedon Jun 22, 2017
@knocte It will be in the 15.3 update, and is in the process of being integrated into the Mono 5.x series (which already contain F# 4.1, but not this fix)
knocte commentedon Jun 23, 2017
Thanks for the info, but what is 15.3 exactly? Is it a minor version number? F# 4.1.15.3? Where is that version number reflected?
cartermp commentedon Jun 23, 2017
15.3 --> VS 2017 Update 3.
VS 2017 is the 15th version of VS and how we refer to it internally. That leaks out into GitHub sometimes out of habit.
knocte commentedon Jun 23, 2017
ok thanks very much @cartermp
NullVoxPopuli commentedon Mar 16, 2018
This came up again.
Using VS Community 2017 - 15.6.2
Visual F# Tools 10.1 for F# 4.1
The error seemed to go away after closing the file, and reopening it, making a change, saving, undoing that change, and saving.
The error re-appears if I save the abstract superclass
So, I have:
and the
exchange-name/RestClientis what gives the error:An implementation of the file or module 'RestClient__2' has already been given.But the base/RestClient.fs only defines
type public IRestClientandtype publicAbstractRestClient`