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

CS8602 should fire within subsequent arguments of validating function #39654

Open
AArnott opened this issue Nov 2, 2019 · 3 comments
Open

CS8602 should fire within subsequent arguments of validating function #39654

AArnott opened this issue Nov 2, 2019 · 3 comments

Comments

@AArnott
Copy link
Contributor

AArnott commented Nov 2, 2019

Version Used: VS 16.5 Preview 1 (29502.12.master)

Steps to Reproduce:

  1. Create a .NET Core 3.0 library or console app.
  2. Install-Package Microsoft.VisualStudio.Validation -Version 15.5.31
  3. Introduce a source file with this content:
using Microsoft;

#nullable enable

class Program
{
    static object? v;
    static void Main(string[] args)
    {
        Verify.Operation(v != null, v.ToString());
        v.ToString();
    }
}

Expected Behavior:

CS8602 identifies that v.ToString() is a dereference of a possibly null value.

Actual Behavior:

No warning is emitted of the null reference.
It seems that the Verify.Operation call, which is annotated to not return if the condition passed as the first argument is false is inappropriately applied as validated even for the subsequent arguments passed to that method.

image

@jcouv
Copy link
Member

jcouv commented Dec 11, 2019

What is the signature of Verify.Operation? Does it have any attributes?
Even better would be to provide a standalone repro (sharplab link for instance). Thanks

@AArnott
Copy link
Contributor Author

AArnott commented Dec 11, 2019

Sure: here is a sharplab link. that demonstrates the problem.

@jcouv
Copy link
Member

jcouv commented Dec 11, 2019

Ah, thanks!
Relates to #29865 (order of effect of nullable attributes)

@jaredpar jaredpar added the Bug label Dec 14, 2019
@jaredpar jaredpar added this to the Compiler.Next milestone Dec 14, 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

4 participants