-
Notifications
You must be signed in to change notification settings - Fork 854
Open
Open
Copy link
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingArea-Compiler-Checking-NameResolutionModule/type name collisions, open behavior, shadowing, global namespaceModule/type name collisions, open behavior, shadowing, global namespaceBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone
Description
Over the years, F# has allowed more things to have the same name without getting confused. This issue is about one such situation where F# still gets confused.
Consider the following code.
module Top
module A =
type B = { C: bool }
module B =
module C =
let x = 0
let y = B.C.x
let z = A.B.C.x
// ^^^^^
// Error FS0728 Field 'C' is not staticExpected behavior
I expected the expressions assigned to y and z to evaluate to the same thing.
Actual behavior
As shown in the code as a comment, the actual behavior is a compile error in the expression assigned to z because the B resolves to the type B instead of the nested submodule B.
At the same time, IntelliSense gives the correct tooltip when hovering over x.

But IntelliSense also gives a tooltip that agrees with the compiler when hovering over C.

Known workarounds
Open module A just before z like this.
open A
let z = B.C.xRelated information
- Operating system
- Edition: Windows 10 Enterprise
- Version: 1909
- OS build: 18363.1198
- .NET SDK: .NET Core 3.1.403
- Visual Studio
- Edition: Enterprise 2019
- Version: 16.7.7
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingArea-Compiler-Checking-NameResolutionModule/type name collisions, open behavior, shadowing, global namespaceModule/type name collisions, open behavior, shadowing, global namespaceBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.
Type
Projects
Status
New