Skip to content

[<RequireQualifiedAccess>] on a DU shadows types in the same module #1253

@Tarmil

Description

@Tarmil

I think this issue is an unfortunate consequence of the way #95 was fixed. Consider the following code:

module A =
    [<RequireQualifiedAccess>]
    type U = | C

    type C() =
        static member M() = ()

Since U has RequireQualifiedAccess, using A.C should unambiguously refer to the class rather than the union case. But as it stands, when I call A.C.M(), the compiler thinks A.C refers to A.U.C and fails with the following:

warning FS0035: This construct is deprecated: The union type for union case 'C' was defined with the RequireQualifiedAccessAttribute. Include the name of the union type ('U') in the name you are using.

  A.C.M();;
  ----^

error FS0039: The field, constructor or member 'M' is not defined

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions