Author freundTech
Recipients BTaskaya, Daniel Moisset, brandtbucher, freundTech, gvanrossum, kj, laurenjl, lys.nikolaou, pablogsal, rhettinger, willingc, xtreak
Date 2021-03-12.21:21:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1615584085.29.0.741353599987.issue42128@roundup.psfhosted.org>
In-reply-to
Content
For the last few days I've been working with pattern matching and it's ast for a bit, while trying to add support for it to mypy.

During this I noticed an inconsistency in the ast:

ast.MatchAs has an attribute name which is of type identifier (in C) and type str (in python).

This seams really inconsistent with the rest of the ast, where identifiers are always wrapped in a ast.Name object. The only other exception to this is ast.Attribute.

Judging from Grammar/python.gram this seems deliberate:

as_pattern[expr_ty]:
    | pattern=or_pattern 'as' target=capture_pattern {
        _Py_MatchAs(pattern, target->v.Name.id, EXTRA) }

Could someone shed some light on why MatchAs directly references an identifier instead of an ast.Name?
History
Date User Action Args
2021-03-12 21:21:25freundTechsetrecipients: + freundTech, gvanrossum, rhettinger, willingc, Daniel Moisset, lys.nikolaou, pablogsal, xtreak, brandtbucher, BTaskaya, kj, laurenjl
2021-03-12 21:21:25freundTechsetmessageid: <1615584085.29.0.741353599987.issue42128@roundup.psfhosted.org>
2021-03-12 21:21:25freundTechlinkissue42128 messages
2021-03-12 21:21:25freundTechcreate