Skip to content

Commit 84e5d08

Browse files
committed
Editorial pass
- Removed duplicate parenthesized_pattern from the primary_pattern production - Fixed relational pattern prose Added a sentence after the grammar: "The relational_expression in a relational_pattern is required to evaluate to a constant value." Replaced backtick-formatted `constant_expression` references with plain prose ("the expression", "the constant expression"). Changed `null_literal` to "a null constant" (it's a semantic constraint, not a syntactic one).
1 parent 378e7f8 commit 84e5d08

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

standard/patterns.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ primary_pattern
3232
| positional_pattern
3333
| property_pattern
3434
| discard_pattern
35-
| parenthesized_pattern
3635
| type_pattern
3736
| relational_pattern
3837
;
@@ -486,11 +485,13 @@ relational_pattern
486485
;
487486
```
488487

488+
The *relational_expression* in a *relational_pattern* is required to evaluate to a constant value.
489+
489490
Relational patterns support the relational operators `<`, `<=`, `>`, and `>=` on all of the built-in types that support such binary relational operators with both operands having the same type: `sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, `float`, `double`, `decimal`, `nint`, `nuint`, and enums.
490491

491-
It is a compile-time error if `constant_expression` evaluates to one of `double.NaN`, `float.NaN`, or `null_literal`.
492+
It is a compile-time error if the expression evaluates to `double.NaN`, `float.NaN`, or a null constant.
492493

493-
When the input value has a type for which a suitable built-in binary relational operator is defined, the evaluation of that operator is taken as the meaning of the relational pattern. Otherwise, the input value is converted to the type of `constant_expression` using an explicit nullable or unboxing conversion. It is a compile-time error if no such conversion exists. The pattern is considered to not match if the conversion fails. If the conversion succeeds, the result of the pattern-matching operation is the result of evaluating the expression `e «op» v` where `e` is the converted input, «op» is the relational operator, and `v` is the `constant_expression`.
494+
When the input value has a type for which a suitable built-in binary relational operator is defined, the evaluation of that operator is taken as the meaning of the relational pattern. Otherwise, the input value is converted to the type of the constant expression using an explicit nullable or unboxing conversion. It is a compile-time error if no such conversion exists. The pattern is considered to not match if the conversion fails. If the conversion succeeds, the result of the pattern-matching operation is the result of evaluating the expression `e «op» v` where `e` is the converted input, «op» is the relational operator, and `v` is the constant expression.
494495

495496
> *Example*:
496497
>

0 commit comments

Comments
 (0)