Open
Labels
Description
Bug report
Bug description:
The language reference defines lambda_expr: "lambda" [parameter_list] ":" expression, reusing parameter_list from the function definition. The grammar explicitly avoids this because:
Lines 922 to 924 in 74b944a
| # lambda_parameters etc. duplicates parameters but without annotations | |
| # or type comments, and if there's no comma after a parameter, we expect | |
| # a colon, not a close parenthesis. (For more, see parameters above.) |
So, it uses parameter: identifier [":" expression] which is incorrect since lambda parameters can't be annotated. A separate lambda_parameter_list family of productions is probably needed, although it's not ideal as it would largely be duplicated. @encukou, what do you think?
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsTodo
Activity
encukou commentedon Sep 2, 2026
Yeah, there's a bunch of similar issues with the hand-written grammar in the docs. Lambdas are section 6.14; I'm currently working on 6.2.8 :)
(Thank you for the review on #154884 btw!)