Add support for multiple provides of the same identifier in TR.

Closes PR 12807.

original commit: 735b84b08310c44933cd5235719cb7f4a647a1c6
This commit is contained in:
Eric Dobson 2012-05-30 20:57:31 -07:00 committed by Sam Tobin-Hochstadt
parent 55c8f085d1
commit c07bd9c067
3 changed files with 22 additions and 6 deletions

View File

@ -0,0 +1,13 @@
#lang racket/load
(module a typed/racket
(define (foo x) (list x))
(provide
(rename-out (foo foo2))
foo))
(module b racket
(require 'a)
(foo 2)
(foo2 3))
(require 'b)

View File

@ -31,7 +31,7 @@
(cond [(s:member i vd (lambda (i j) (free-identifier=? i (binding-name j)))) => car]
[else #f]))
;; generate-contract-defs : dict[id -> def-binding] dict[id -> id] id -> syntax
;; generate-contract-defs : dict[id -> def-binding] dict[id -> list[id]] id -> syntax
;; defs: defines in this module
;; provs: provides in this module
;; pos-blame-id: a #%variable-reference for the module
@ -118,7 +118,10 @@
new-id))])]
;; otherwise, not defined in this module, not our problem
[else (values #'(begin) internal-id)]))
;; do-one : id id -> syntax
(for/list ([(internal-id external-id) (in-dict provs)])
;; Build the final provide with auxilliary definitions
(for/list ([(internal-id external-ids) (in-dict provs)])
(define-values (defs id) (mk internal-id))
#`(begin #,defs (provide (rename-out [#,id #,external-id])))))
(define provide-forms
(for/list ([external-id (in-list external-ids)])
#`(rename-out [#,id #,external-id])))
#`(begin #,defs (provide #,@provide-forms))))

View File

@ -305,11 +305,11 @@
[i:id
(when (def-stx-binding? (dict-ref def-tbl #'i #f))
(set! syntax-provide? #t))
(dict-set h #'i #'i)]
(dict-update h #'i (lambda (tail) (cons #'i tail)) '())]
[((~datum rename) in out)
(when (def-stx-binding? (dict-ref def-tbl #'in #f))
(set! syntax-provide? #t))
(dict-set h #'in #'out)]
(dict-update h #'in (lambda (tail) (cons #'out tail)) '())]
[(name:unknown-provide-form . _)
(tc-error "provide: ~a not supported by Typed Racket" (syntax-e #'name.name))]
[_ (int-err "unknown provide form")])))]