Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Expose local phase levels to rules

Aperta
#379 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Ambito
tooling

Direzione di ricerca

Inizia esaminando l’attuale hook dell’observer dell’espansione di Resyntax e il flusso di analisi del sorgente, concentrandoti su come vengono rappresentate le visite e su come le regole ottengono le informazioni sulla fase. L’issue suggerisce di esporre alle regole un livello di fase locale; il completamento dovrebbe includere il refactoring riuscito dell’esempio begin-for-syntax, preservando il comportamento della fase 0.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Racket
Stelle
70
Fork
11
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di jackfirth/resyntax

Tutte le issue di jackfirth/resyntax

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.