Handle multiple instantiation of a single expression.

svn: r12148
This commit is contained in:
Sam Tobin-Hochstadt 2008-10-27 20:06:31 +00:00
parent d60ae208e1
commit 0c44c5ce40

View File

@ -52,6 +52,14 @@
(define (split-last l) (define (split-last l)
(let-values ([(all-but last-list) (split-at l (sub1 (length l)))]) (let-values ([(all-but last-list) (split-at l (sub1 (length l)))])
(values all-but (car last-list)))) (values all-but (car last-list))))
(define (in-improper-stx stx)
(let loop ([l stx])
(match l
[#f null]
[(cons a b) (cons a (loop b))]
[e (list e)])))
(for/fold ([ty ty])
([inst (in-improper-stx inst)])
(cond [(not inst) ty] (cond [(not inst) ty]
[(not (or (Poly? ty) (PolyDots? ty))) [(not (or (Poly? ty) (PolyDots? ty)))
(tc-error/expr #:return (Un) "Cannot instantiate non-polymorphic type ~a" ty)] (tc-error/expr #:return (Un) "Cannot instantiate non-polymorphic type ~a" ty)]
@ -87,7 +95,7 @@
[_ [_
(instantiate-poly ty (map parse-type (syntax->list inst)))]))] (instantiate-poly ty (map parse-type (syntax->list inst)))]))]
[else [else
(instantiate-poly ty (map parse-type (syntax->list inst)))])) (instantiate-poly ty (map parse-type (syntax->list inst)))])))
;; typecheck an identifier ;; typecheck an identifier
;; the identifier has variable effect ;; the identifier has variable effect