Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Expose local phase levels to rules

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

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu bằng việc điều tra expansion observer hook hiện tại của Resyntax và luồng phân tích mã nguồn, tập trung vào cách các lượt thăm được biểu diễn và cách các rule nhận thông tin về phase. Issue đề xuất cung cấp cho các rule một mức phase cục bộ; việc hoàn thành nên bao gồm refactoring thành công ví dụ begin-for-syntax trong khi vẫn giữ nguyên hành vi của phase 0.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

This rule:

(define-refactoring-rule redundant-or
  #:description "This `or` expression does nothing and can be replaced with its subexpression."
  #:literals (or)
  (or a1:id a2:id)
  #:when (free-identifier=? #'a1 #'a2)
  a1)

Fails to refactor this code:

(begin-for-syntax
  (define x 42)
  (or x x))

The reason for that is that free-identifier=? checks if two identifiers have the same binding at a specific phase level, and by default it uses (syntax-local-phase-level). This is reasonable for macros, which set (syntax-local-phase-level) to the level of the macro invocation. But refactoring rules aren't run during macro expansion, so (syntax-local-phase-level) always returns zero. This lets free-identifier=? in rules work fine on phase 0 code, but it fails on phase 1 code such as code inside begin-for-syntax.

Resyntax ought to expose the local phase level to rules. I'm not sure how to get that information out of the expander using the current expansion observer hook, but it's probably possible. One way to expose it to rules might be to add a (resyntax-local-phase-level) parameter and let rules use that to access the phase level. On the Resyntax source analysis side, there could be an expansion-visit struct / record type containing the syntax object that the expander visited and the phase level the visit occurred at.

Ngôn ngữ chính
Racket
Star
70
Fork
11
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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.

Issue khác của jackfirth/resyntax

Tất cả issue của jackfirth/resyntax

Issue tương tự

Thêm issue về DevTools

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.