Make heterogenous vector typechecking not double typecheck the arguments.

This commit is contained in:
Eric Dobson 2014-03-14 21:53:59 -07:00
parent a7d6809243
commit 74f8dc7436
3 changed files with 22 additions and 8 deletions

View File

@ -109,14 +109,18 @@
(tc-expr/check e (ret t))
t)))]
[(tc-result1: (app resolve (HeterogeneousVector: ts)))
(unless (= (length ts) (syntax-length #'(args ...)))
(tc-error/expr "expected vector with ~a elements, but got ~a"
(length ts)
(make-HeterogeneousVector (stx-map tc-expr/t #'(args ...)))))
(for ([e (in-syntax #'(args ...))]
[t (in-list ts)])
(tc-expr/check e (ret t)))
expected]
(cond
[(= (length ts) (syntax-length #'(args ...)))
(ret
(make-HeterogeneousVector
(for/list ([e (in-syntax #'(args ...))]
[t (in-list ts)])
(tc-expr/check/t e (ret t))))
-true-filter)]
[else
(tc-error/expr #:return (ret -Bottom)
"expected vector with ~a elements, but got ~a"
(length ts) (make-HeterogeneousVector (stx-map tc-expr/t #'(args ...))))])]
;; If the expected type is a union, then we examine just the parts
;; of the union that are vectors. If there's only one of those,
;; we re-run this whole algorithm with that. Otherwise, we treat

View File

@ -0,0 +1,5 @@
#;
(exn-pred 2)
#lang typed/racket
(ann (vector (ann 1 Symbol)) (Vector Number Symbol))

View File

@ -2593,6 +2593,11 @@
[tc-e (reverse (list 'x 'y))
#:ret (ret (-Tuple (list (-val 'y) (-val 'x))))
#:expected (ret (-Tuple (list (-val 'y) (-val 'x))) -no-filter -no-obj)]
[tc-err (vector 1 2)
#:ret (ret (make-HeterogeneousVector (list -Byte -Byte)) -false-filter -empty-obj)
#:expected (ret (make-HeterogeneousVector (list -Byte -Byte)) -false-filter -no-obj)]
)
(test-suite
"tc-literal tests"