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

unconstrained type parameter is null compiles when not targeting C# 8 #35550

Closed
YairHalberstadt opened this issue May 7, 2019 · 2 comments
Closed
Labels
Area-Compilers Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Milestone

Comments

@YairHalberstadt
Copy link
Contributor

Version Used: VS 16.0.3

Steps to Reproduce:

Compile the following program with LangVersion set to 7.3

public class C {
    public bool M<T>(T t) {
        return t is null;
    }
}

Expected Behavior: Error: Cannot convert null to type parameter 'T' because it could be a non-nullable value type.

Actual Behavior: Compiles without error.

@jcouv
Copy link
Member

jcouv commented May 7, 2019

Yes, the t is null should be gated on a language version. This was fixed in 16.1 (PR #34695)
I'll go ahead and close as fixed.
FYI @gafter

@jcouv jcouv closed this as completed May 7, 2019
@jcouv jcouv added this to the 16.1 milestone May 7, 2019
@jcouv jcouv added the Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented label May 7, 2019
@YairHalberstadt
Copy link
Contributor Author

I see it's a duplicate now - sorry about that. GitHub search is far from perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
None yet
Development

No branches or pull requests

2 participants