Conflict between pragmatic locations and pure spans
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
The PEG parser produces locations for an AST that span the entire AST node. This is well defined, and has a number of desirable properties such as the span of a node including all its children's spans.
Unfortunately, this does not produce good locations for tracing and debugging, so we transform some locations in the compiler.
This is problematic as it means that tools producing as AST (e.g. pytest) need to second guess what transformations that the compiler will make.
I proposed moving these transformations in the parser in https://github.com/python/cpython/issues/94694, but as @pablogsal points out, this means that tools which consume the AST (e.g. type checkers) need to undo the transformations to get the original spans back.
The core problem is that there are tools that consume the AST produced by the parser, and tools that produce ASTs for consumption by the compiler, and they want subtly different ASTs.
One possible fix for this is to add a keyword argument to compile() to specify whether it should modify the locations. This would allow pytest, etc. to pass location information through compile() unmodified when needed.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng việc đọc issue 94694 và cách parser/compiler xử lý các location của AST. So sánh nhu cầu của các AST consumer với các công cụ tạo AST cho compile(), sau đó xác định liệu một tùy chọn để bảo toàn các location có đủ hay không. Được xem là hoàn thành khi hành vi của location được xác định mà không yêu cầu các công cụ phải đoán hoặc hoàn tác các biến đổi của compiler.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- compilers
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100