-
Couldn't load subscription status.
- Fork 4.2k
Improve compiler error recovery for null coalesce assignment operator #80907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Improve compiler error recovery for null coalesce assignment operator #80907
Conversation
| if (leftOperand.HasAnyErrors || rightOperand.HasAnyErrors) | ||
| TypeSymbol leftType = leftOperand.Type; | ||
|
|
||
| var rightOperandTargetType = leftType switch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var rightOperandTargetType = leftType switch | ||
| { | ||
| { IsReferenceType: true } or { IsValueType: false, TypeKind: TypeKind.TypeParameter } => leftType, | ||
| { IsValueType: true } when leftType.IsNullableType() => leftType.GetNullableUnderlyingType(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| else if (rightOperand.HasAnyErrors) | ||
| { | ||
| leftOperand = BindToTypeForErrorRecovery(leftOperand); | ||
| var conversion = GenerateConversionForAssignment(rightOperandTargetType, rightOperand, diagnostics, ConversionForAssignmentFlags.CompoundAssignment); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| else if (rightOperand.HasAnyErrors) | ||
| { | ||
| leftOperand = BindToTypeForErrorRecovery(leftOperand); | ||
| var conversion = GenerateConversionForAssignment(rightOperandTargetType, rightOperand, diagnostics, ConversionForAssignmentFlags.CompoundAssignment); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Done with review pass (commit 1), nests were not looked at. It looks like the change affects scenarios that fall outside of the stated goal of this PR. I suggest making adjustments to affect only error scenarios with target typed |
| else if (rightOperand.HasAnyErrors) | ||
| { | ||
| leftOperand = BindToTypeForErrorRecovery(leftOperand); | ||
| var conversion = GenerateConversionForAssignment(rightOperandTargetType, rightOperand, diagnostics, ConversionForAssignmentFlags.CompoundAssignment); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| { | ||
| leftOperand = BindToTypeForErrorRecovery(leftOperand); | ||
| var conversion = GenerateConversionForAssignment(rightOperandTargetType, rightOperand, diagnostics, ConversionForAssignmentFlags.CompoundAssignment); | ||
| return new BoundNullCoalescingAssignmentOperator(node, leftOperand, conversion, rightOperandTargetType, hasErrors: true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redo of #74218
Related to #73894