python / python/cpython

`lambda` grammar in the language reference incorrectly allows annotations

Đang mở
#156,675 1 bình luận 0 reaction 2 người được giao Xem trên GitHub

@encukou đang làm issue này rồi.

Từ ngày 30/8/2026.

docs topic-parser type-bug
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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:

https://github.com/python/cpython/blob/74b944afe32049191674c747e060d8d67a2a1b17/Grammar/python.gram#L922-L924

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.