Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive Open declaration can be removed when using extension for builder #16227

Open
Tracked by #15408
BoundedChenn31 opened this issue Nov 3, 2023 · 0 comments
Labels
Area-LangService-CodeFixes Code fixes associated with diagnostics Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone

Comments

@BoundedChenn31
Copy link
Contributor

Here is the half-done maybe CE
Repro steps

Here is the half-done maybe CE, extension for it that adds Bind-overload and usage attempt:

namespace Case1

module MaybeBuilder =
    
    type MaybeBuilder() =
        member inline _.Bind(optionValue: 'T option, f) =
            match optionValue with
            | None -> None
            | Some value -> f value

        member inline _.Return maybeNull =
           if isNull maybeNull then None else Some maybeNull

        member inline _.Delay f = f

        member inline _.Run f = f()

    let maybe = MaybeBuilder()


module MaybeBuilderExtension =
    
    open MaybeBuilder
    
    type MaybeBuilder with
        member inline _.Bind(maybeNull: 'T, f) =
            if isNull maybeNull then None else f maybeNull


module Usage =
    open MaybeBuilder
    open MaybeBuilderExtension // TODO: false positive

    let foo (s: string) =
        maybe {
            let! a = s
            return a
        }

Visual Studio marks open MaybeBuilderExtension as safe to remove.
2023-11-03_233943

However it would break compilation of code because we actually use Bind from extension.

Expected behavior

open for builder extension isn't marked as unnecessary.

Actual behavior

It's marked as unnecessary.

Known workarounds
.

Related information

.NET SDK: 7.0.403
Visual Studio 17.7.6

@github-actions github-actions bot added this to the Backlog milestone Nov 3, 2023
@psfinaki psfinaki added the Area-LangService-CodeFixes Code fixes associated with diagnostics label Nov 7, 2023
@psfinaki psfinaki mentioned this issue Nov 7, 2023
85 tasks
@0101 0101 added Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. and removed Needs-Triage labels Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-LangService-CodeFixes Code fixes associated with diagnostics Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Projects
None yet
Development

No branches or pull requests

3 participants