Fix up the contracts so that they properly refer to locally defined variables.

svn: r13527
This commit is contained in:
Stevie Strickland 2009-02-12 03:51:40 +00:00
parent 12110acfe3
commit 8656e7e918
2 changed files with 27 additions and 1 deletions

View File

@ -602,7 +602,7 @@
(raise-stx-err "cannot export syntax from a unit" name))
(set-var-info-exported?! v loc)
(when (pair? (syntax-e ctc))
(set-var-info-ctc! v (cdr (syntax-e ctc))))))
(set-var-info-ctc! v (localify (cdr (syntax-e ctc)) def-ctx)))))
(syntax->list (localify #'evars def-ctx))
(syntax->list #'elocs)
(syntax->list #'ectcs))

View File

@ -599,3 +599,29 @@
(unit/c (import) (export))
3)
not-a-unit))
;; Adding a test to make sure that contracts can refer
;; to other parts of the signature.
(module m3 scheme
(define-signature toy-factory^
((contracted
[build-toys (-> integer? (listof toy?))]
[repaint (-> toy? symbol? toy?)]
[toy? (-> any/c boolean?)]
[toy-color (-> toy? symbol?)])))
(define-unit simple-factory@
(import)
(export toy-factory^)
(printf "Factory started.\n")
(define-struct toy (color) #:transparent)
(define (build-toys n)
(for/list ([i (in-range n)])
(make-toy 'blue)))
(define (repaint t col)
(make-toy col))))