Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4346912
Add support for pattern additions
RexJaeschke Dec 7, 2023
aaa0ab7
Address lined comments
BillWagner Feb 19, 2026
8e5ada2
Address general comment
BillWagner Feb 19, 2026
80d6451
Fix build issue
BillWagner Feb 19, 2026
f14e1a5
Add closing tag
BillWagner Feb 19, 2026
5679cb6
fix output
BillWagner Feb 19, 2026
4c38af2
more fixing the output
BillWagner Feb 19, 2026
50ff3de
Add LDM decisions
BillWagner Feb 19, 2026
a53e879
Add subsumption and exhaustiveness
BillWagner Feb 23, 2026
d4139ac
Editorial pass
BillWagner Feb 27, 2026
8defb68
Use consistent `ITuple`
BillWagner Feb 27, 2026
3558bd0
Add consistent "Is applicable to" language
BillWagner Feb 27, 2026
4dea818
binding vs. precedence in the `is` statement.
BillWagner Feb 27, 2026
3de2fb7
Add a couple notes
BillWagner Mar 3, 2026
76cdcc5
Fix broken test code.
BillWagner Apr 17, 2026
840ca4e
Fix ANTLR grammar validator tests for pattern-matching enhancements
BillWagner Apr 17, 2026
ce598db
Remove pattern-enhancement source trailing whitespace
BillWagner Oct 13, 2026
858d6e7
Restore approved #1691 subsumption and exhaustiveness precedence
BillWagner Oct 13, 2026
7814bcf
patterns and def. assignment
BillWagner Nov 24, 2026
651beca
Parenthesized-pattern semantics
BillWagner Nov 24, 2026
6fdc99e
Relational-pattern comparison and conversions
BillWagner Nov 24, 2026
63b8f1c
Constant and relational-pattern narrowing
BillWagner Nov 24, 2026
3bffcac
Pattern recognition and outer capture
BillWagner Nov 24, 2026
6f328ce
Normative references and terminology
BillWagner Nov 24, 2026
25115ee
Logical-pattern applicability
BillWagner Nov 24, 2026
8ed3eaf
Grouping, evaluation order, and precedence
BillWagner Nov 25, 2026
6cfd713
type-pattern restrictions
BillWagner Nov 25, 2026
c76c5ec
Contextual pattern-keyword recognition
BillWagner Nov 25, 2026
5fb12da
ITuple fallback
BillWagner Nov 25, 2026
bcd37c5
Discard recognition and name lookup
BillWagner Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions standard/expressions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 12 Expressions

Check warning on line 2 in standard/expressions.md

View workflow job for this annotation

GitHub Actions / word-converter

Markdown to Word Converter - MDC032

Line length 92 > maximum 83; : anonymous_function_modifier? anonymous_function_signature '=>' anonymous_function_body

Check warning on line 2 in standard/expressions.md

View workflow job for this annotation

GitHub Actions / word-converter

Markdown to Word Converter - MDC032

Line length 84 > maximum 83; : null_conditional_member_access null_forgiving_operator? '(' argument_list? ')'
## 12.1 General

Check warning on line 3 in standard/expressions.md

View workflow job for this annotation

GitHub Actions / word-converter

Markdown to Word Converter - MDC032

Line length 86 > maximum 83; | 'stackalloc' unmanaged_type? '[' constant_expression? ']' stackalloc_initializer

Check warning on line 3 in standard/expressions.md

View workflow job for this annotation

GitHub Actions / word-converter

Markdown to Word Converter - MDC032

Line length 85 > maximum 83; | null_conditional_element_access null_forgiving_operator? '(' argument_list? ')'

An expression is a sequence of operators and operands. This clause defines the syntax, order of evaluation of operands and operators, and meaning of expressions.
Expand Down Expand Up @@ -4430,7 +4430,7 @@
as it does not effect the resulting parse at all, but the prose gets messier. For C#9 this decision should be checked to be
still valid after the new pattern changes.
-->
When recognising a *relational_expression* ([§12.14.1](expressions.md#12141-general)) if both the “*relational_expression* `is` *type*” and “*relational_expression* `is` *constant_pattern*” alternatives are applicable, and *type* resolves to an accessible type, then the “*relational_expression* `is` *type*” alternative shall be chosen.
The recognition of the *type* following `is` is subject to the type-recognition restriction in [§11.2.1](patterns.md#1121-general). When the same token sequence can be recognised both as “*relational_expression* `is` *type*” and as “*relational_expression* `is` *pattern*”, and *type* resolves to an accessible type, the “*relational_expression* `is` *type*” alternative shall be chosen.

The `is` operator is described in [§12.14.12](expressions.md#121412-the-is-operator) and the `as` operator is described in [§12.14.13](expressions.md#121413-the-as-operator).

Expand Down Expand Up @@ -4852,7 +4852,7 @@
- `E` does not designate a value or does not have a type.
- The pattern `P` is not applicable ([§11.2](patterns.md#112-pattern-forms)) to the type `T`.

Every *single_variable_designation* of the pattern introduces a new local variable that is *definitely assigned* ([§9.4](variables.md#94-definite-assignment)) when the corresponding *relational_expression* tests `true` ([§9.4.4.34](variables.md#94434-is-pattern-expressions)).
Every *single_variable_designation* of the pattern introduces a new local variable. Its definite-assignment state is determined as specified in [§9.4.4.34](variables.md#94434-is-pattern-expressions).

### 12.14.13 The as operator

Expand Down
19 changes: 11 additions & 8 deletions standard/lexical-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ These productions occur in contexts where a value can occur in an expression, an

If a sequence of tokens can be parsed, in context, as one of the disambiguated productions including an optional *type_argument_list* ([§8.4.2](types.md#842-type-arguments)), then the token immediately following the closing `>` token shall be examined and if it is:

- one of `( ) ] } : ; , . ? == != | ^ && || & [`; or
- one of `( ) ] } : ; , . ? == != | ^ && || & [ =>`; or
- one of the relational operators `< <= >= is as`; or
- a contextual query keyword appearing inside a query expression.
- In certain contexts, *identifier* is treated as a disambiguating token. Those contexts are where the sequence of tokens being disambiguated is immediately preceded by one of the keywords `is`, `case` or `out`, or arises while parsing the first element of a tuple literal (in which case the tokens are preceded by `(` or `:` and the identifier is followed by a `,`) or a subsequent element of a tuple literal.

then the *type_argument_list* shall be retained as part of the disambiguated production and any other possible parse of the sequence of tokens discarded. Otherwise, the tokens parsed as a *type_argument_list* shall not be considered to be part of the disambiguated production, even if there is no other possible parse of those tokens.

Expand Down Expand Up @@ -604,13 +605,13 @@ A ***contextual keyword*** is an identifier-like sequence of characters that has

```ANTLR
contextual_keyword
: 'add' | 'alias' | 'ascending' | 'async' | 'await'
| 'by' | 'descending' | 'dynamic' | 'equals' | 'from'
| 'get' | 'global' | 'group' | 'into' | 'join'
| 'let' | 'nameof' | 'nint' | 'notnull' | 'nuint'
| 'on' | 'orderby' | 'partial' | 'remove' | 'select'
| 'set' | 'unmanaged' | 'value' | 'var' | 'when'
| 'where' | 'yield'
: 'add' | 'alias' | 'and' | 'ascending' | 'async'
| 'await' | 'by' | 'descending' | 'dynamic' | 'equals'
| 'from' | 'get' | 'global' | 'group' | 'into'
| 'join' | 'let' | 'nameof' | 'nint' | 'not'
| 'notnull' | 'nuint' | 'on' | 'or' | 'orderby'
| 'partial' | 'remove' | 'select' | 'set' | 'unmanaged'
| 'value' | 'var' | 'when' | 'where' | 'yield'
;
```

Expand All @@ -624,6 +625,8 @@ Another example such disambiguation is the contextual keyword `await` ([§12.9.9

Just as with keywords, contextual keywords can be used as ordinary identifiers by prefixing them with the `@` character.

The recognition of `not`, `and`, and `or` as pattern operators is specified in [Logical pattern](patterns.md#logical-pattern-new-clause-logical-pattern).

> *Note*: When used as contextual keywords, these identifiers cannot contain *Unicode_Escape_Sequence*s. *end note*

### 6.4.5 Literals
Expand Down
Loading
Loading