Skip to content

Commit 97896fa

Browse files
authored
Update reference syntax documentation with named tuples (#23493)
Fix #22237 Given named tuple is a stable feature since 3.7, I updated the `docs/_docs/reference/syntax.md`.
2 parents 8a14de3 + 33cd8c3 commit 97896fa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/_docs/reference/syntax.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ SimpleType ::= SimpleLiteral
199199
| Singleton ‘.’ id
200200
| Singleton ‘.’ ‘type’
201201
| ‘(’ [Types] ‘)’
202+
| ‘(’ NameAndType {‘,’ NameAndType} ‘)’
202203
| Refinement
203204
| SimpleType TypeArgs
204205
| SimpleType ‘#’ id
@@ -220,6 +221,7 @@ ContextBounds ::= ContextBound
220221
| '{' ContextBound {',' ContextBound} '}'
221222
ContextBound ::= Type ['as' id]
222223
Types ::= Type {‘,’ Type}
224+
NameAndType ::= id ‘:’ Type
223225
```
224226

225227
### Expressions
@@ -268,6 +270,7 @@ SimpleExpr ::= SimpleRef
268270
| ‘new’ ConstrApp {‘with’ ConstrApp} [TemplateBody]
269271
| ‘new’ TemplateBody
270272
| ‘(’ [ExprsInParens] ‘)’
273+
| ‘(’ NamedExprInParens {‘,’ NamedExprInParens} ‘)’
271274
| SimpleExpr ‘.’ id
272275
| SimpleExpr ‘.’ MatchClause
273276
| SimpleExpr TypeArgs
@@ -287,6 +290,7 @@ ExprInParens ::= PostfixExpr ‘:’ Type | Expr
287290
ParArgumentExprs ::= ‘(’ [ExprsInParens] ‘)’
288291
| ‘(’ ‘using’ ExprsInParens ‘)’
289292
| ‘(’ [ExprsInParens ‘,’] PostfixExpr ‘*’ ‘)’
293+
NamedExprInParens ::= id ‘=’ ExprInParens
290294
ArgumentExprs ::= ParArgumentExprs
291295
| BlockExpr
292296
BlockExpr ::= <<< (CaseClauses | Block) >>>
@@ -333,7 +337,9 @@ SimplePattern1 ::= SimpleRef
333337
| SimplePattern1 ‘.’ id
334338
PatVar ::= varid
335339
| ‘_’
340+
NamedPattern ::= id ‘=’ Pattern
336341
Patterns ::= Pattern {‘,’ Pattern}
342+
| NamedPattern {‘,’ NamedPattern}
337343
338344
ArgumentPatterns ::= ‘(’ [Patterns] ‘)’
339345
| ‘(’ [Patterns ‘,’] PatVar ‘*’ ‘)’

0 commit comments

Comments
 (0)