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:
|
# 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
Bug report
Bug description:
The language reference defines
lambda_expr: "lambda" [parameter_list] ":" expression, reusingparameter_listfrom the function definition. The grammar explicitly avoids this because:cpython/Grammar/python.gram
Lines 922 to 924 in 74b944a
So, it uses
parameter: identifier [":" expression]which is incorrect since lambda parameters can't be annotated. A separatelambda_parameter_listfamily 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