Accidental name bindings with structural pattern matching
Offen
@brandtbucher arbeitet bereits daran.
Seit 22.5.2022.
interpreter-core
type-bug
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 36k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug report
Your environment
- CPython versions tested on: 3.10.2, 3.11.0a6
- Operating system and architecture: macOS Monterey, Version 12.3.1. Mac mini running M1, Apple silicon.
Steps to reproduce:
Run the code in bug.py, attached.
The output on my Mac mini is:
% python bug.py
Cheese Sandwich
Search for 'match' in the code. Notice that one of the terms matches
the only str in the list, "Cheese Sandwich". Later we create a dataclass
of type PersonHeight. On the last line of the file, we print the type
of one of the fields in a PersonHeight object. Note that it is not <class 'str'> as it should be,
but "Cheese Sandwich"
If we comment out the match expression, we get the correct behavior
(see comment below in code)
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.