Warn when importing bad bindings with `only'.

This commit is contained in:
Alex Shinn 2011-12-04 13:43:34 +09:00
parent cd708b9f90
commit f2502229e6

View file

@ -49,6 +49,15 @@
(define (symbol-append a b)
(string->symbol (string-append (symbol->string a) (symbol->string b))))
;; (define (warn msg . args)
;; (display msg (current-error-port))
;; (display ":" (current-error-port))
;; (for-each (lambda (a)
;; (display " " (current-error-port))
;; (write a (current-error-port)))
;; args)
;; (newline (current-error-port)))
(define (to-id id) (if (pair? id) (car id) id))
(define (from-id id) (if (pair? id) (cdr id) id))
(define (id-filter pred ls)
@ -67,12 +76,15 @@
(and (not (eq? 'only (car x)))
(module-exports
(find-module (car mod-name+imports)))))))
;; (if (not (eq? 'only (car x)))
;; (let ((unbound
;; (id-filter (lambda (i) (not (memq i imp-ids))) (cddr x))))
;; (if (pair? unbound)
;; (warn "import excepting unbound identifiers" unbound))))
(cons (car mod-name+imports)
(case (car x)
((only)
(if (not imp-ids)
(cddr x)
(id-filter (lambda (i) (memq i (cddr x))) imp-ids)))
(cddr x))
((except)
(id-filter (lambda (i) (not (memq i (cddr x)))) imp-ids))
((rename)