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

Roslyn allows additional *primary_constraints* when the notnull primary constraint is used #75892

Open
BillWagner opened this issue Nov 13, 2024 · 0 comments
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@BillWagner
Copy link
Member

Version Used:

C# 12 and C# 13, with LangVersion set from C# 8 through C# 13.

Use the following code:

using System.IO;

public class C1<T> where T : notnull, Stream {}
public class C2<T> where T : notnull, Stream? {}

See sharplab

Expected Behavior:

According to 15.2.5 only one primary_constraint can be specified. The Nullable reference types specification - 9.0 classifies the notnull constraint as a primary constraint. Therefore, both the above declarations should be prohibited.

Actual Behavior:

Both declarations are allowed.

See dotnet/csharpstandard#1178 (comment)

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 13, 2024
@BillWagner BillWagner changed the title Roslyn allows additional *primary_constraints* when the notnull primary constraing is used Roslyn allows additional *primary_constraints* when the notnull primary constraint is used Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant