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

Easier way for rules to check identifier usages

Aperta
#400 0 commenti 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
devtools

Direzione di ricerca

Inizia tracciando il codice di pattern matching delle regole di refactoring e di confronto degli identificatori; l'issue non indica file o test specifici. Definisci cosa significa “completato” per un pattern (~usage id) che fa corrispondere gli utilizzi di free-identifiers, gli utilizzi di syntax-free-identifiers e il default proposto a livello di fase, verificando anche i requisiti correlati in #379.

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

Descrizione

enhancement

Consider the hash-ref-set!-to-hash-ref! rule:

(define-refactoring-rule hash-ref-set!-to-hash-ref!
  #:description "This expression can be replaced with a simpler, equivalent `hash-ref!` expression."
  #:literals (hash-ref hash-set! define)
  (hash-ref
   h1:id
   k1:pure-expression
   (_:lambda-by-any-name
    ()
    (define v1:id initializer:value-initializer)
    (hash-set! h2:id k2:pure-expression v2:id)
    v3:id))
  #:when (free-identifier=? #'h1 #'h2)
  #:when (syntax-free-identifier=? #'k1 #'k2)
  #:when (free-identifier=? #'v1 #'v2)
  #:when (free-identifier=? #'v1 #'v3)
  (hash-ref! h1 k1 initializer.failure-result-form))

It needs to do quite a bit of work to check that some identifiers are usages of others. Those free-identifier=? checks ought to be easier to write. It might be useful to have a (~usage id) syntax pattern that matches any identifier that's free-identifier=? to #'id. That would let me write the above rule like this:

(define-refactoring-rule hash-ref-set!-to-hash-ref!
  #:description "This expression can be replaced with a simpler, equivalent `hash-ref!` expression."
  #:literals (hash-ref hash-set! define)
  (hash-ref
   h:id
   k1:pure-expression
   (_:lambda-by-any-name
    ()
    (define v:id initializer:value-initializer)
    (hash-set! (~usage h) k2:pure-expression (~usage v))
    (~usage v)))
  #:when (syntax-free-identifier=? #'k1 #'k2)
  (hash-ref! h k1 initializer.failure-result-form))

Might be worthwhile to make it match any syntax object that's syntax-free-identifier=? too. This could also help with #379, as ~usage could default to (resyntax-local-phase-level) (or whatever equivalent I come up with) instead of (syntax-local-phase-level) like free-identifier=? does.

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.