False positive CS8619 warning using `-=` with `byte?`
#82,552 opened on Feb 26, 2026
Repository metrics
- Stars
- (20,414 stars)
- PR merge metrics
- (Avg merge 7d 9h) (270 merged PRs in 30d)
Description
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?.