Skip to content
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

[FS0250] - 'ModuleSuffix' needs to be added explicitly #9868

Closed
JaggerJo opened this issue Aug 4, 2020 · 3 comments
Closed

[FS0250] - 'ModuleSuffix' needs to be added explicitly #9868

JaggerJo opened this issue Aug 4, 2020 · 3 comments

Comments

@JaggerJo
Copy link

JaggerJo commented Aug 4, 2020

When a module (module A = ()) and a type (type A = { a : string }) have the same name a "Module" suffix is automatically added to the name of the module. This seems to only work if the type and the module are located in the same file.

Repro steps
Create a Project with two Files

Lib.fs

namespace Repro

type A = { a: string }

Program.fs

namespace Repro

module A = ()

Expected behavior

Compilation works and and a ModuleSuffix is added implicitly. This works when both types are declared in the same file.

Program.fs

namespace Repro

type A = { a: string }

module A =
    ()

Actual behavior

Compilation fails with:
Lib.fs(3, 6): [FS0250] A module and a type definition named 'A' occur in namespace 'Repro' in two parts of this assembly

Known workarounds

[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] needs to be added manually.

@abelbraaksma
Copy link
Contributor

Isn't this "by design" or was this relaxed at some point? I still have plenty of code with that attribute.

@cartermp
Copy link
Contributor

cartermp commented Aug 4, 2020

This is currently by design, though the RFC mentions a "compilation unit" instead of explicitly talking about per-file. I think this could be filed as a language suggestion here: https://github.com/fsharp/fslang-suggestions

@cartermp cartermp closed this as completed Aug 4, 2020
@JaggerJo
Copy link
Author

JaggerJo commented Aug 4, 2020

@cartermp Thanks, wasn't sure but suspected that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants