dotnet / dotnet/fsharp

Wrong error message when referencing nested classes

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

Description

The error message is wrong and misleading when accessing a non-existent member of a nested static class.

Here's a sample solution reproducing the problem.
[Repro.zip](https://github.com/dotnet/fsharp/files/6192576/Repro.zip)

Create a C# class library with this code:
```csharp
namespace ClassLibrary1
{
public class T {
public class G {
public static readonly string A = "";
}
}
}
```

Create an F# Console Application with this code:
```fsharp
[]
let main argv =
ClassLibrary1.T.G.B |> ignore
0
```
Have the F# project reference the C# project.
Try to compile.

**Expected behavior**

The error message should state that B is not a member of G.

**Actual behavior**

The error message is:
```
error FS0039: The type 'T' does not define the field, constructor or member 'G'.
```

This is wrong, since T does define G.

Seen on Visual Studio 16.9.2.

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.