dotnet / dotnet/fsharp

Error FS0001 instead of FS0249 for overlapped names

Open
#4,601 1 comment 1 reaction 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

This kind of error might be confusing, especially for beginners learning namespaces and type extensions.

#### Repro steps

Consider two files with a type and the type extension:

```fsharp
// file1.fs
namespace A
type U = T of value : int
```
and
```fsharp
// file2.fs
namespace A
type U = // typo, should be with
member u.Value =
match u with
| T value -> value // error FS0001
```

Compilation order is `file1.fs` then `file2.fs`. There are two errors in the code: type extension should be in form of `type U with ...` and should be placed in a module. But we are considering just the first one.

#### Expected behavior

```
error FS0249: Two type definitions named 'U' occur in namespace 'A' in two parts of this assembly
```

#### Actual behavior

```
error FS0001:
This expression was expected to have type
'A.U'
but here has type
'A.U'
```

#### Related information

```
dotnet --version
> 2.1.100
```

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.