False positive CS8619 warning using `-=` with `byte?`
#82 552 ouverte le 26 févr. 2026
Métriques du dépôt
- Stars
- (20 414 stars)
- Métriques de merge PR
- (Merge moyen 6j 17h) (256 PRs mergées en 30 j)
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?.