Skip to content

null default value for non-nullable parameter should warn #26626

@jcouv

Description

@jcouv

Example

public class C 
{
    public void M(string x = null) 
    {
    }
}

For comparison, a local declaration does warn:

public class C 
{
    public void M() 
    {
        string x = null; // warning CS8600: Converting null literal or possible null value to non-nullable type.
    }
}

Found in nullable dogfood.
Tagging @cston

Note: there are some IDE tests (in CSharpDeclareAsNullableCodeFixTests) for this bug, which should be unskipped.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions