@@ -120,6 +120,25 @@ The value pattern will be extended to support simple names
120120if they are prefixed by a leading dot. The lookup is performed following the
121121standard Python name resolution rules.
122122
123+ Interaction with capture patterns
124+ ---------------------------------
125+
126+ **Capture patterns ** are only assigned **after ** a case matches but
127+ before the guard clause is evaluated. Any lookup will resolve to an
128+ existing variable if one exists, or raise an error.
129+
130+ .. code-block :: python-console
131+
132+ >>> match [1, 1]:
133+ ... case [x, *_, .x]:
134+ ... pass
135+ ...
136+ Traceback (most recent call last):
137+ File "<python-input-0>", line 2, in <module>
138+ case [x, *_, .x]:
139+ ^
140+ NameError: name 'x' is not defined
141+
123142 Grammar
124143-------
125144
@@ -288,6 +307,18 @@ Standard name resolution covers all of these scopes without additional syntax.
288307In addition, ``nonlocal.NAME `` does not have an equivalent expression form
289308elsewhere in Python.
290309
310+ Reuse existing typing constructs (``Literal[NAME] ``)
311+ ----------------------------------------------------
312+
313+ It was suggested to reuse ``Literal `` from :py:class: `typing.Literal ` to
314+ match simple names. So far no names other than ``_ `` have a dedicated meaning
315+ in the match statement mini-syntax. Assigning one to ``Literal `` would
316+ thus be surprising. Additionally, subscription is not defined for use in
317+ match cases yet. Using it here would limit future options unnecessarily.
318+ Lastly, :py:class: `typing.Literal ` only supports literal values as arguments,
319+ e.g. ``1 ``, ``"Hello" `` or ``True ``. Allowing simple names only inside
320+ match cases would therefore be confusing.
321+
291322Distinguishing by case of the name
292323----------------------------------
293324
@@ -355,6 +386,15 @@ Note the difference from the class pattern ``case int():``, which matches
355386object itself.
356387
357388
389+ Change History
390+ ==============
391+
392+ * 25-Sep-2026
393+
394+ - Clarify interaction with **capture patterns **
395+ - Added rejected idea for ``Literal[NAME] ``
396+
397+
358398Copyright
359399=========
360400
0 commit comments