Allow re-definition at TR top-level
original commit: e513cdc1c445f7d2ca15ef7033caada29ccf63ff
This commit is contained in:
parent
d89b936cc5
commit
aeee35bccb
|
@ -73,8 +73,8 @@
|
|||
(define (unregister-type id)
|
||||
(free-id-table-remove! the-mapping id))
|
||||
|
||||
(define (finish-register-type id)
|
||||
(unless (maybe-finish-register-type id)
|
||||
(define (finish-register-type id [top-level? #f])
|
||||
(unless (or top-level? (maybe-finish-register-type id))
|
||||
(tc-error/expr #:stx id "Duplicate definition for ~a" (syntax-e id)))
|
||||
(void))
|
||||
|
||||
|
|
|
@ -167,7 +167,8 @@
|
|||
(map make-def-binding vars ts))]
|
||||
;; if this already had an annotation, we just construct the binding reps
|
||||
[(andmap (lambda (s) (lookup-type s (lambda () #f))) vars)
|
||||
(for-each finish-register-type vars)
|
||||
(define top-level? (eq? (syntax-local-context) 'top-level))
|
||||
(for ([var (in-list vars)]) (finish-register-type var top-level?))
|
||||
(map (lambda (s) (make-def-binding s (lookup-type s))) vars)]
|
||||
;; special case to infer types for top level defines
|
||||
[else
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#lang racket/load
|
||||
|
||||
;; Test that variable redefinition works at the top-level
|
||||
|
||||
(require typed/racket)
|
||||
(: x Integer)
|
||||
(define x 3)
|
||||
(define x 5)
|
||||
|
Loading…
Reference in New Issue
Block a user