X-Git-Url: https://git.lukelau.me/?p=scheme.git;a=blobdiff_plain;f=typecheck.scm;fp=typecheck.scm;h=e96f6943767e1c5ab463398d11146d8f8ae450ce;hp=219b010202a7f7a0127847e8372ea7e064a05efb;hb=4a6161c0db78e4739433377861c0fa89b92619be;hpb=2fb532c612fb077a99938b54d59a9520b71772b0 diff --git a/typecheck.scm b/typecheck.scm index 219b010..e96f694 100644 --- a/typecheck.scm +++ b/typecheck.scm @@ -339,12 +339,13 @@ ; input: a list of binds ((x . y) (y . 3)) ; returns: pair of verts, edges ((x y) . (x . y)) (define (graph bs) + (define (go bs orig-bs) (define (find-refs prog) (ast-collect (lambda (x) (case (ast-type x) ; only count a reference if its a binding - ['var (if (assoc x bs) (list x) '())] + ['var (if (assoc x orig-bs) (list x) '())] [else '()])) prog)) (if (null? bs) @@ -358,10 +359,11 @@ (rest (if (null? (cdr bs)) (cons '() '()) - (graph (cdr bs)))) + (go (cdr bs) orig-bs))) (total-verts (cons vert (car rest))) (total-edges (append edges (cdr rest)))] (cons total-verts total-edges)))) + (go bs bs)) (define (successors graph v) (define (go v E)