roslyn
roslyn copied to clipboard
Fix confusing `ref` usage error messages
Fixes #62756
@dotnet/roslyn-compiler ready for review
Done with review pass (commit 3)
Consider an alternative approach - simply adjusting the wording of the error message to include the RHS of an assignment situation. For example, instead of saying: "Cannot assign to variable 'x' because it is a readonly variable." We could say: "Cannot assign to variable 'x' or use it as the right hand side of a ref assignment because it is a readonly variable." Then we wouldn't need to make any changes to the analysis that compiler performs.
Consider an alternative approach - simply adjusting the wording of the error message to include the RHS of an assignment situation. For example, instead of saying: "Cannot assign to variable 'x' because it is a readonly variable." We could say: "Cannot assign to variable 'x' or use it as the right hand side of a ref assignment because it is a readonly variable." Then we wouldn't need to make any changes to the analysis that compiler performs.
Sounds good, I didn't realize that is a possibility. Opened a new PR for that: #64241