Get rid of "An explicit conversion exists (are you missing a cast?)" from CS0266 #48431
Labels
Area-Compilers
Concept-Diagnostic Clarity
The issues deals with the ease of understanding of errors and warnings.
Projects
Milestone
CS0266 has the following error message:
It comes up pretty much everywhere where the target type doesn't match the expression type, since almost any type can be explicitly converted to any other type. However in 99% of cases, it's not the correct solution, and so is just noise - it can also be confusing for users, who may add an explicit cast (thinking the diagnostic means an explicit cast operator exists) only to find things blow up at runtime.
I would suggest either getting rid of this diagnostic completely, or using
CS0029
"Cannot implicitly convert type 'int' to 'string'" in most cases, and adding new diagnostics for the following cases:The text was updated successfully, but these errors were encountered: