dotnet / dotnet/fsharp

In a separate project, a namespace sharing the same name as a module with ModuleSuffix is not visible

Open
#14,798 5 comments 0 reactions 0 assignees View on GitHub
Area-Compiler-Checking-NameResolution Feature Request Needs-RFC
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 22h
Merged PRs (30d)
144

Description

If a project with a module with the same name as a namespace occur in the same project (but different files), only the things in the module will be visible in other projects.

Steps to reproduce the problem:

1. Create a module with a value in it with the ModuleSuffix attribute
```fsharp
[]
module NamespaceModuleCollision.TopLevel

let test = 5
```
2. Create a second module inside a namespace with the same name as the above module, also with a value in it
```fsharp
module NamespaceModuleCollision.TopLevel.Sub

let test2 = 5
```
3. In a different project, reference the first project and attempt to use the values from both modules
```fsharp
let _ = NamespaceModuleCollision.TopLevel.Sub.test2 //Compiles fine

let _ = NamespaceModuleCollision.TopLevel.test //fails to compile

open NamespaceModuleCollision.TopLevel
let _ = test //fails to compile
```

[NamespaceModuleCollision.zip](https://github.com/dotnet/fsharp/files/10818194/NamespaceModuleCollision.zip)

**Expected behavior**

The values in the NamespaceModuleCollision.TopLevel can be referenced.

**Actual behavior**

The values in the NamespaceModuleCollision.TopLevel module result in compiler errors:

error FS0039: The value, constructor, namespace or type 'test' is not defined.
error FS0039: The value or constructor 'test' is not defined. Maybe you want one of the following:↔ Text

**Known workarounds**

Name the module and namespace different things.

**Related information**
Reproduced in a net7.0 project

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.