Make inst not do crazy splitting.
This commit is contained in:
parent
a6789164d8
commit
4766a94470
|
@ -48,9 +48,6 @@
|
|||
;; do-normal-inst : Syntax (Option Syntax) Type -> Type
|
||||
;; Instantiate a normal polymorphic type
|
||||
(define (do-normal-inst stx inst ty)
|
||||
(define (split-last l)
|
||||
(let-values ([(all-but last-list) (split-at l (sub1 (length l)))])
|
||||
(values all-but (car last-list))))
|
||||
(match ty
|
||||
[(list ty)
|
||||
(list
|
||||
|
@ -73,22 +70,18 @@
|
|||
;; In this case, we need to check the last thing. If it's a dotted var, then we need to
|
||||
;; use instantiate-poly-dotted, otherwise we do the normal thing.
|
||||
;; In the case that the list is empty we also do the normal thing
|
||||
(let ((stx-list (syntax->list inst)))
|
||||
(if (null? stx-list)
|
||||
(instantiate-poly ty (map parse-type stx-list))
|
||||
(let-values ([(all-but-last last-stx) (split-last stx-list)])
|
||||
(match (syntax-e last-stx)
|
||||
[(cons last-ty-stx (? identifier? last-id-stx))
|
||||
(unless (bound-index? (syntax-e last-id-stx))
|
||||
(tc-error/stx last-id-stx "~a is not a type variable bound with ..." (syntax-e last-id-stx)))
|
||||
(if (= (length all-but-last) (sub1 (PolyDots-n ty)))
|
||||
(let* ([last-id (syntax-e last-id-stx)]
|
||||
[last-ty (extend-tvars (list last-id) (parse-type last-ty-stx))])
|
||||
(instantiate-poly-dotted ty (map parse-type all-but-last) last-ty last-id))
|
||||
(tc-error/expr #:return (Un) "Wrong number of fixed type arguments to polymorphic type ~a:\nexpected: ~a\ngot: ~a"
|
||||
ty (sub1 (PolyDots-n ty)) (length all-but-last)))]
|
||||
[_
|
||||
(instantiate-poly ty (map parse-type stx-list))]))))]
|
||||
(match (syntax->list inst)
|
||||
[(list ty-stxs ... (app syntax-e (cons bound-ty-stx (? identifier? bound-id))))
|
||||
(unless (bound-index? (syntax-e bound-id))
|
||||
(tc-error/stx bound-id "~a is not a type variable bound with ..." (syntax-e bound-id)))
|
||||
(if (= (length ty-stxs) (sub1 (PolyDots-n ty)))
|
||||
(let* ([last-id (syntax-e bound-id)]
|
||||
[last-ty (extend-tvars (list last-id) (parse-type bound-ty-stx))])
|
||||
(instantiate-poly-dotted ty (map parse-type ty-stxs) last-ty last-id))
|
||||
(tc-error/expr #:return (Un) "Wrong number of fixed type arguments to polymorphic type ~a:\nexpected: ~a\ngot: ~a"
|
||||
ty (sub1 (PolyDots-n ty)) (length ty-stxs)))]
|
||||
[stx-list
|
||||
(instantiate-poly ty (map parse-type stx-list))])]
|
||||
[else
|
||||
(instantiate-poly ty (stx-map parse-type inst))]))]
|
||||
[_ (if inst
|
||||
|
|
Loading…
Reference in New Issue
Block a user