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

var nullability analysis regression #52925

Closed
davidmilligan opened this issue Apr 26, 2021 · 4 comments · Fixed by #53691
Closed

var nullability analysis regression #52925

davidmilligan opened this issue Apr 26, 2021 · 4 comments · Fixed by #53691

Comments

@davidmilligan
Copy link

davidmilligan commented Apr 26, 2021

Version Used:
Microsoft.Net.Compilers 3.9.0

Steps to Reproduce:

#nullable enable

class C<T> where T : notnull
{
    void M(T initial, System.Func<T, T?> selector)
    {
        // ⚠ CS8600 Converting null literal or possible null value to non-nullable type.
        //                                                     ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
        for (var current = initial; current != null; current = selector(current))
        {
        }
    }
}

Expected Behavior:

No CS8600 warning

Actual Behavior:

CS8600 warning

Notes:
This code snippet previous compiled without warning on 3.8.0, so this appears to be a regression. It also only happens with the constraint T : notnull. T : class for example does not give the warning

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 26, 2021
@jcouv
Copy link
Member

jcouv commented May 7, 2021

Confirmed, I'm still seeing this unexpected warning in 3.10 (VS 16.10) at the moment.

@RikkiGibson
Copy link
Contributor

Also occurs with class? constraint and in the absence of constraints.

@jcouv jcouv added this to the 17.0 milestone May 24, 2021
@jcouv jcouv removed the untriaged Issues and PRs which have not yet been triaged by a lead label May 24, 2021
@jcouv jcouv assigned jcouv and unassigned RikkiGibson May 26, 2021
@jcouv jcouv removed the 3 - Working label May 28, 2021
@jcouv
Copy link
Member

jcouv commented May 28, 2021

Fixed for 17.0 (p1 or p2)

@jcouv
Copy link
Member

jcouv commented Jun 2, 2021

Also backported fix to 16.11

@jcouv jcouv modified the milestones: 17.0, 16.11 Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants