-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Implement Null Coalescing and Null Coalescing assignment operators #10636
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
Changes from all commits
ecb94dd
15119cf
0cb1592
cfd73f9
137a37b
94ad01f
dee8092
9826e69
9e599c4
8fd9572
02dc105
4e8019e
a9af2ab
0e93e14
771a86d
1a4887e
73b8982
36f4b85
d530fcd
3f0f3d1
8f39bbb
dea5793
4cf6ba4
268a609
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -416,6 +416,12 @@ public enum TokenKind | |
| /// <summary>The ternary operator '?'.</summary> | ||
| QuestionMark = 100, | ||
|
|
||
| /// <summary>The null conditional assignment operator '??='.</summary> | ||
| QuestionQuestionEquals = 101, | ||
|
|
||
| /// <summary>The null coalesce operator '??'.</summary> | ||
| QuestionQuestion = 102, | ||
|
|
||
| #endregion Operators | ||
|
|
||
| #region Keywords | ||
|
|
@@ -592,46 +598,51 @@ public enum TokenFlags | |
| /// <summary> | ||
| /// The precedence of the logical operators '-and', '-or', and '-xor'. | ||
| /// </summary> | ||
| BinaryPrecedenceLogical = 1, | ||
| BinaryPrecedenceLogical = 0x1, | ||
|
|
||
| /// <summary> | ||
| /// The precedence of the bitwise operators '-band', '-bor', and '-bxor' | ||
| /// </summary> | ||
| BinaryPrecedenceBitwise = 2, | ||
| BinaryPrecedenceBitwise = 0x2, | ||
|
|
||
| /// <summary> | ||
| /// The precedence of comparison operators including: '-eq', '-ne', '-ge', '-gt', '-lt', '-le', '-like', '-notlike', | ||
| /// '-match', '-notmatch', '-replace', '-contains', '-notcontains', '-in', '-notin', '-split', '-join', '-is', '-isnot', '-as', | ||
| /// and all of the case sensitive variants of these operators, if they exists. | ||
| /// </summary> | ||
| BinaryPrecedenceComparison = 3, | ||
| BinaryPrecedenceComparison = 0x5, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since enum's are treated like constants, this would be a breaking change for compiled projects right?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this will be a breaking change. We are expecting the impact to very small though. I have updated the PR Context in description with more details. |
||
|
|
||
| /// <summary> | ||
| /// The precedence of null coalesce operator '??'. | ||
| /// </summary> | ||
| BinaryPrecedenceCoalesce = 0x7, | ||
|
|
||
| /// <summary> | ||
| /// The precedence of the binary operators '+' and '-'. | ||
| /// </summary> | ||
| BinaryPrecedenceAdd = 4, | ||
| BinaryPrecedenceAdd = 0x9, | ||
|
|
||
| /// <summary> | ||
| /// The precedence of the operators '*', '/', and '%'. | ||
| /// </summary> | ||
| BinaryPrecedenceMultiply = 5, | ||
| BinaryPrecedenceMultiply = 0xa, | ||
|
|
||
| /// <summary> | ||
| /// The precedence of the '-f' operator. | ||
| /// </summary> | ||
| BinaryPrecedenceFormat = 6, | ||
| BinaryPrecedenceFormat = 0xc, | ||
|
|
||
| /// <summary> | ||
| /// The precedence of the '..' operator. | ||
| /// </summary> | ||
| BinaryPrecedenceRange = 7, | ||
| BinaryPrecedenceRange = 0xd, | ||
|
|
||
| #endregion Precedence Values | ||
|
|
||
| /// <summary> | ||
| /// A bitmask to get the precedence of binary operators. | ||
| /// </summary> | ||
| BinaryPrecedenceMask = 0x00000007, | ||
| BinaryPrecedenceMask = 0x0000000f, | ||
|
|
||
| /// <summary> | ||
| /// The token is a keyword. | ||
|
|
@@ -669,7 +680,7 @@ public enum TokenFlags | |
| SpecialOperator = 0x00001000, | ||
|
|
||
| /// <summary> | ||
| /// The token is one of the assignment operators: '=', '+=', '-=', '*=', '/=', or '%=' | ||
| /// The token is one of the assignment operators: '=', '+=', '-=', '*=', '/=', '%=' or '??=' | ||
adityapatwardhan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// </summary> | ||
| AssignmentOperator = 0x00002000, | ||
|
|
||
|
|
@@ -854,8 +865,8 @@ public static class TokenTraits | |
| /* Shr */ TokenFlags.BinaryOperator | TokenFlags.BinaryPrecedenceComparison | TokenFlags.CanConstantFold, | ||
| /* Colon */ TokenFlags.SpecialOperator | TokenFlags.DisallowedInRestrictedMode, | ||
| /* QuestionMark */ TokenFlags.TernaryOperator | TokenFlags.DisallowedInRestrictedMode, | ||
| /* Reserved slot 3 */ TokenFlags.None, | ||
| /* Reserved slot 4 */ TokenFlags.None, | ||
| /* QuestionQuestionEquals */ TokenFlags.AssignmentOperator, | ||
| /* QuestionQuestion */ TokenFlags.BinaryOperator | TokenFlags.BinaryPrecedenceCoalesce, | ||
| /* Reserved slot 5 */ TokenFlags.None, | ||
| /* Reserved slot 6 */ TokenFlags.None, | ||
| /* Reserved slot 7 */ TokenFlags.None, | ||
|
|
@@ -1052,8 +1063,8 @@ public static class TokenTraits | |
| /* Shr */ "-shr", | ||
| /* Colon */ ":", | ||
| /* QuestionMark */ "?", | ||
| /* Reserved slot 3 */ string.Empty, | ||
| /* Reserved slot 4 */ string.Empty, | ||
| /* QuestionQuestionEquals */ "??=", | ||
| /* QuestionQuestion */ "??", | ||
| /* Reserved slot 5 */ string.Empty, | ||
| /* Reserved slot 6 */ string.Empty, | ||
| /* Reserved slot 7 */ string.Empty, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.