Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Expose local phase levels to rules

オープン
#379 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
領域
tooling

調査の方向性

まず、Resyntax の現在の expansion observer hook とソース解析フローを調査し、訪問がどのように表現され、ルールがどのようにフェーズ情報を取得しているかに注目してください。この issue では、ルールにローカルなフェーズレベルを公開することが提案されています。完了条件には、フェーズ 0 の動作を維持したまま、begin-for-syntax の例のリファクタリングを成功させることを含めるべきです。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Racket
スター
70
フォーク
11
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

jackfirth/resyntax のほかの issue

jackfirth/resyntax の issue をすべて見る

似ている issue

DevTools の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。