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

Track nullable assignment through ?ref:ref receiver #33365

Open
gafter opened this issue Feb 13, 2019 · 1 comment
Open

Track nullable assignment through ?ref:ref receiver #33365

gafter opened this issue Feb 13, 2019 · 1 comment

Comments

@gafter
Copy link
Member

gafter commented Feb 13, 2019

At the LDM on 2019-02-13, we agreed on our intent to track assignments through ref expressions (though we will not track aliasing through ref variables). The following would be a good test. We currently report the third and fourth expected warnings, but we fail to report the first and second.

#nullable enable
    static void M(bool b, string nonNull, string? maybeNull)
    {
        string? x = nonNull;
        string? y = nonNull;
        (b ? ref x : ref y) = maybeNull;
        x.ToString(); // should be warning: possible dereference of a null reference
        y.ToString(); // should be warning: possible dereference of a null reference

        x = maybeNull;
        y = maybeNull;
        (b ? ref x : ref y) = nonNull;
        x.ToString(); // should be warning: possible dereference of a null reference
        y.ToString(); // should be warning: possible dereference of a null reference
    }
@jcouv
Copy link
Member

jcouv commented Jul 8, 2019

Moved to post C# 8 RTM.

@gafter gafter added the Bug label Sep 19, 2019
@jaredpar jaredpar modified the milestones: Compiler.Next, Backlog Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants