Repository navigation
parser: promote char operands of unary and shift operators to int - #24
Merged
Merged
Conversation
The unary '-', '+', and '~' operators and the shift operators rejected a char operand, although C# converts it to int, as it does for sbyte, byte, short, and ushort. For example, -'a', ~'a', 'a' << 1, and 1 << 'a' failed with "cannot be applied to operand(s) of type 'System.Char'". Apply unary numeric promotion to these operands in one place and include char in it. The shift operators still reject a count that does not convert to int, such as '1 << 1u', and a value that is not an integer, such as '1.5 >> 1'.
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.
The unary
-,+, and~operators and the shift operators rejected acharoperand, although C# converts it toint, as it does forsbyte,byte,short, andushort. For example,-'a'failed withUnary operator '-' cannot be applied to operand of type 'System.Char', and'a' << 1failed withOperator '<<' cannot be applied to operands of type 'System.Char' and 'System.Int32'. Binary arithmetic and comparisons withcharalready worked.This PR applies unary numeric promotion to these operands in one place and includes
charin it. The shift operators still reject a count that does not convert toint, such as1 << 1u, and a value that is not an integer, such as1.5 >> 1.