Skip to content

False positive Open declaration can be removed when having records with the same name #16226

@BoundedChenn31

Description

@BoundedChenn31

Repro steps

Consider this code

namespace Case2

module RecordA =
    type Record = { Foo: string }

module RecordB =
    type Record = { Bar: string }

module Use =
    open RecordB // actually not required
    open RecordA
    open RecordB // TODO: false positive
    
    let convertBToA (recordB: Record) =
        { Foo = recordB.Bar }

VS marks second open RecordB as unnecessary. Removal of it breaks compilation because we actually need RecordB.Record and open RecordA shadows it.

2023-11-03_224641

Expected behavior

Suggested refactorings do not break compilation and highlight correct targets for change

Actual behavior

Suggested refactoring breaks compilation.

Known workarounds
.

Provide any related information (optional):

.NET SDK: 7.0.403
Visual Studio 17.7.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-LangService-CodeFixesCode fixes associated with diagnosticsBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    No fields configured for Bug.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions