Skip to content

Commit cfd73f9

Browse files
Fix issues after merge and test fix
1 parent 0cb1592 commit cfd73f9

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/System.Management.Automation/engine/parser/token.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,7 @@ public enum TokenKind
420420
QuestionEquals = 101,
421421

422422
/// <summary>The null coalesce operator '??'.</summary>
423-
QuestionQuestion = 101,
424-
425-
/// <summary>The null conditional member access operator '?.'.</summary>
426-
QuestionDot = 102,
423+
QuestionQuestion = 102,
427424

428425
#endregion Operators
429426

@@ -865,7 +862,7 @@ public static class TokenTraits
865862
/* QuestionMark */ TokenFlags.TernaryOperator | TokenFlags.DisallowedInRestrictedMode,
866863
/* QuestionEquals */ TokenFlags.AssignmentOperator,
867864
/* QuestionQuestion */ TokenFlags.BinaryOperator,
868-
/* QuestionDot */ TokenFlags.SpecialOperator | TokenFlags.DisallowedInRestrictedMode,
865+
/* Reserved slot 5 */ TokenFlags.None,
869866
/* Reserved slot 6 */ TokenFlags.None,
870867
/* Reserved slot 7 */ TokenFlags.None,
871868
/* Reserved slot 8 */ TokenFlags.None,
@@ -1062,7 +1059,7 @@ public static class TokenTraits
10621059
/* Colon */ ":",
10631060
/* QuestionEquals */ "?=",
10641061
/* QuestionQuestion */ "??",
1065-
/* QuestionDot */ "?.",
1062+
/* Reserved slot 4 */ string.Empty,
10661063
/* Reserved slot 5 */ string.Empty,
10671064
/* Reserved slot 6 */ string.Empty,
10681065
/* Reserved slot 7 */ string.Empty,

src/System.Management.Automation/engine/parser/tokenizer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4994,9 +4994,6 @@ internal Token NextToken()
49944994
return this.NewToken(TokenKind.Colon);
49954995

49964996
case '?' when InExpressionMode():
4997-
return this.NewToken(TokenKind.QuestionMark);
4998-
4999-
case '?':
50004997
c1 = PeekChar();
50014998

50024999
if (c1 == '=')
@@ -5011,7 +5008,7 @@ internal Token NextToken()
50115008
return CheckOperatorInCommandMode(c, c1, TokenKind.QuestionQuestion);
50125009
}
50135010

5014-
return ScanGenericToken(c);
5011+
return this.NewToken(TokenKind.QuestionMark);
50155012

50165013
case '\0':
50175014
if (AtEof())

test/powershell/Language/Operators/NullConditional.Tests.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ Describe 'NullConditionalOperations' -tag 'CI' {
6363
}
6464

6565
Context 'Null coalesce operator ??' {
66+
BeforeEach {
67+
$x = $null
68+
}
6669

6770
It 'Variable does not exist' {
6871
$variableDoesNotExist ?? 100 | Should -Be 100

0 commit comments

Comments
 (0)