diff --git a/src/System.CommandLine/Parsing/Token.cs b/src/System.CommandLine/Parsing/Token.cs index 7b656c9886..9fae4842ac 100644 --- a/src/System.CommandLine/Parsing/Token.cs +++ b/src/System.CommandLine/Parsing/Token.cs @@ -66,7 +66,7 @@ internal Token(string? value, TokenType type, Symbol? symbol, int position) /// The first . /// The second . /// if the objects are equal. - public static bool operator ==(Token left, Token right) => left.Equals(right); + public static bool operator ==(Token? left, Token? right) => left is null ? right is null : left.Equals(right); /// /// Checks if two specified instances have different values. @@ -74,6 +74,7 @@ internal Token(string? value, TokenType type, Symbol? symbol, int position) /// The first . /// The second . /// if the objects are not equal. - public static bool operator !=(Token left, Token right) => !left.Equals(right); + public static bool operator !=(Token? left, Token? right) => left is null ? right is not null : !left.Equals(right); + } }