Repository navigation
parser: simplify VisitBinary - #86
Merged
Merged
Conversation
VisitBinary resolved the factory before the switch, so the result was unused for ?? and the string + operator, and ResolveBinaryOperatorFactory kept an entry for ?? only because of that. Resolve the factory after the switch, still outside the try block, so that an unknown operator keeps failing with NotSupportedException, and remove the ?? entry. Order the remaining entries by precedence. No behavior change.
The operands of && and || and the condition of ?: were converted to bool by the same steps: ApplyImplicitConversion, a null check, and MissingImplicitConversion. Move them to ApplyBooleanConversion. The error now names the type of the operand after the null literal conversion rather than before it. The two differ only for the null literal on the left of && or || with an operand of a nullable value type on the right, where the literal takes the type of that operand: null && NullBool now reports 'System.Nullable`1[System.Boolean]' instead of 'System.Object'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
VisitBinaryresolved the operator factory before theswitch, so the result was unused for??and the string+operator, andResolveBinaryOperatorFactorykept an entry for??only for that call. The operands of&&and||and the condition of?:were converted toboolby the same three steps:ApplyImplicitConversion, a null check, andMissingImplicitConversion.This PR resolves the factory after the
switch, removes the??entry, and orders the remaining entries by precedence. The factory is still resolved outside thetryblock, so an unknown operator in a hand-builtExpr.Binarykeeps failing withNotSupportedException. The conversion toboolmoves toApplyBooleanConversion.One error message changes: it now names the type of the operand after the null literal conversion. This matters only for the null literal on the left of
&&or||with an operand of a nullable value type on the right.null && NullBoolnow reportsSystem.Nullable`1[System.Boolean]instead ofSystem.Object, the same asNullBool && null. A test covers the new message. Expression trees and other error messages are unchanged.