Skip to content

False positive CS8619 warning using -= with byte? #82552

@jeremysalwen

Description

@jeremysalwen

Version Used: 9.0.205

Steps to Reproduce:

Compile a file a file containing

byte? b = 1;
b -= 1;

.NET Lab link: https://lab.razor.fyi/#41Li4gooyk8vSszVSy4WEkmqLEm1V0hSsFUwtOZKUtAF0V5MycVRnByXPn05NTldgCWBsYIRAA

Diagnostic Id:

Nullability of reference types in value of type 'int?' doesn't match target type 'byte?'.CS8619

Expected Behavior:
No warning, since subtracting 1 from a nullable byte is fine.

Actual Behavior:
CS8619 warning appears.

Note: Even if somehow there should be a warning since -= should never be used with byte? types, there still is a bug here in that the warning message is incorrect, since the nullablility of int? does match the nullability of byte?.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions