dotnet / dotnet/fsharp

Misleading error when a type and a namespace share the same name

Open
#17,827 0 comments 0 reactions 0 assignees View on GitHub
Area-Diagnostics Bug Impact-Low
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

Consider this library project:

File1.fs:
```fsharp
namespace Ns.TypeName
```

File2.fs:
```fsharp
namespace Ns

type TypeName = { Field: int }
```

There's a name collision between the namespace in the first file and the type in the second one, and there's an error building this project. However, the error is misleading:
```
File1.fs(1,14): Error FS0247 :
A namespace and a module named 'Ns.TypeName' both occur in two parts of this assembly
```

When trying to investigate such an error, you try to find a module `TypeName`, but there's none, so it's quite hard to diagnose on bigger projects.

Here's the repro project: [SameNameNamespaceType.zip](https://github.com/user-attachments/files/17221650/SameNameNamespaceType.zip).

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.