fixed bug in dependency checking for #:rest variables (and removed printfs)

This commit is contained in:
Robby Findler 2010-07-31 09:28:22 -05:00
parent 8f6080733f
commit d75536161c
2 changed files with 30 additions and 7 deletions

View File

@ -132,9 +132,10 @@ and then operates on it to generate the expanded form
;; no dups in the rest var ;; no dups in the rest var
(when (istx-rst istx) (when (istx-rst istx)
(when (rst-vars (istx-rst istx))
(not-range-bound (rst-vars (istx-rst istx))))
(no-var-dups (rst-var (istx-rst istx)))) (no-var-dups (rst-var (istx-rst istx))))
;; dependent arg variables are all bound, but not to a range variable ;; dependent arg variables are all bound, but not to a range variable
(for ([an-arg (in-list (istx-args istx))]) (for ([an-arg (in-list (istx-args istx))])
(let ([a-vars (arg-vars an-arg)]) (let ([a-vars (arg-vars an-arg)])
@ -154,14 +155,12 @@ and then operates on it to generate the expanded form
[sp '()]) [sp '()])
(define (link from to) (define (link from to)
(printf "linking ~s => ~s\n" from to)
(set! sp (cons from sp)) (set! sp (cons from sp))
(free-identifier-mapping-put! (free-identifier-mapping-put!
neighbors from neighbors from
(cons to (free-identifier-mapping-get neighbors from (λ () '()))))) (cons to (free-identifier-mapping-get neighbors from (λ () '())))))
(define (no-links from) (define (no-links from)
(printf "no links ~s\n" from)
(set! sp (cons from sp)) (set! sp (cons from sp))
(free-identifier-mapping-put! neighbors from '())) (free-identifier-mapping-put! neighbors from '()))
@ -182,10 +181,18 @@ and then operates on it to generate the expanded form
[else [else
(no-links (res-var a-res))]))) (no-links (res-var a-res))])))
(let ([a-rst (istx-rst istx)])
(when a-rst
(cond
[(rst-vars a-rst)
(for ([nvar (in-list (rst-vars a-rst))])
(link (rst-var a-rst) nvar))]
[else
(no-links (rst-var a-rst))])))
(for ([var (in-list sp)]) (for ([var (in-list sp)])
(let loop ([var var] (let loop ([var var]
[visited '()]) [visited '()])
(printf "var ~s\n" var)
(cond (cond
[(free-identifier-mapping-get safe var (λ () #f)) [(free-identifier-mapping-get safe var (λ () #f))
(void)] (void)]

View File

@ -65,6 +65,15 @@ test cases:
any) any)
; => unknown dependent variable ; => unknown dependent variable
(->i ([x (y) number?])
[y number?])
; => domain cannot depend on a range variable
(->i ()
#:rest [x (y) number?]
[y number?])
; => domain cannot depend on a range variable
(->i ([x (x) number?]) (->i ([x (x) number?])
any) any)
; => cyclic dependencies not allowed ; => cyclic dependencies not allowed
@ -81,6 +90,11 @@ test cases:
;; => cyclic depenencies ;; => cyclic depenencies
(->i ()
#:rest [x (x) number?]
any)
; => error cyclic dependencies
(->i ([x (y) number?] (->i ([x (y) number?]
[y number?]) [y number?])
any) any)
@ -91,8 +105,10 @@ test cases:
[y number?])) [y number?]))
; => no syntax error ; => no syntax error
(->i ([x (y) number?]) (->i ()
[y number?]) #:rest [x number?]
; => domain cannot depend on a range variable [y (x) number?])
;; => no syntax error
|# |#