use free-id=? instead of bound-id=? for letrec
analysis
With the current macro expander, either should work, but `free-id=?` is arguably the right choice for determining that two identifiers refer to the same binding.
This commit is contained in:
parent
f5f6a77dfd
commit
1469306a8e
|
@ -184,16 +184,16 @@
|
|||
|
||||
;; Set up vertices for Tarjan's algorithm, where each letrec-values
|
||||
;; clause is a vertex but mapped in the table for each of the clause names
|
||||
(define vertices (make-bound-id-table))
|
||||
(define vertices (make-free-id-table))
|
||||
(for ([clause other-clauses])
|
||||
(match-define (lr-clause names expr) clause)
|
||||
(define relevant-free-vars
|
||||
(for/list ([var (in-list (free-vars expr))]
|
||||
#:when (member var flat-names bound-identifier=?))
|
||||
#:when (member var flat-names free-identifier=?))
|
||||
var))
|
||||
(define vertex (make-vertex clause relevant-free-vars))
|
||||
(for ([name (in-list names)])
|
||||
(bound-id-table-set! vertices name vertex)))
|
||||
(free-id-table-set! vertices name vertex)))
|
||||
|
||||
(define components (tarjan vertices))
|
||||
|
||||
|
@ -201,7 +201,7 @@
|
|||
(define (no-self-cycle? vertex)
|
||||
(match-define (lr-clause names _) (vertex-data vertex))
|
||||
(for/and ([id (in-list names)])
|
||||
(andmap (λ (id2) (not (bound-identifier=? id id2)))
|
||||
(andmap (λ (id2) (not (free-identifier=? id id2)))
|
||||
(vertex-adjacent vertex))))
|
||||
|
||||
;; The components with only one entry are non-recursive if they also
|
||||
|
|
Loading…
Reference in New Issue
Block a user