Fix typechecking of andmap/ormap on dotted lists.
This commit is contained in:
parent
0821ca8717
commit
c60b3d8b03
|
@ -22,6 +22,12 @@
|
||||||
#:for-label
|
#:for-label
|
||||||
(reverse k:reverse list list* cons map andmap ormap))
|
(reverse k:reverse list list* cons map andmap ormap))
|
||||||
|
|
||||||
|
(define-syntax-class boolmap
|
||||||
|
#:literal-sets (list-literals)
|
||||||
|
#:attributes (default)
|
||||||
|
(pattern andmap #:attr default #t)
|
||||||
|
(pattern ormap #:attr default #f))
|
||||||
|
|
||||||
(define-tc/app-syntax-class (tc/app-list expected)
|
(define-tc/app-syntax-class (tc/app-list expected)
|
||||||
#:literal-sets (list-literals)
|
#:literal-sets (list-literals)
|
||||||
(pattern (~and form (map f arg0 arg ...))
|
(pattern (~and form (map f arg0 arg ...))
|
||||||
|
@ -58,17 +64,18 @@
|
||||||
;; TODO fix double typechecking
|
;; TODO fix double typechecking
|
||||||
[(res0 res) (tc/app-regular #'form expected)]))
|
[(res0 res) (tc/app-regular #'form expected)]))
|
||||||
;; ormap/andmap of ... argument
|
;; ormap/andmap of ... argument
|
||||||
(pattern (~and form ((~or andmap ormap) f arg))
|
(pattern (~and form (m:boolmap f arg))
|
||||||
(match-let* ([arg-ty (single-value #'arg)]
|
(match-let* ([arg-ty (tc-expr/t #'arg)]
|
||||||
[ft (tc-expr #'f)])
|
[ft (tc-expr #'f)])
|
||||||
(match (match arg-ty
|
(match (match arg-ty
|
||||||
;; if the argument is a ListDots
|
;; if the argument is a ListDots
|
||||||
[(tc-result1: (ListDots: t bound))
|
[(ListDots: t bound)
|
||||||
;; just check that the function applies successfully to the element type
|
;; just check that the function applies successfully to the element type
|
||||||
(tc/funapp #'f #'(arg) ft (list (ret (substitute Univ bound t))) expected)]
|
(extend-tvars (list bound)
|
||||||
|
(tc/funapp #'f #'(arg) ft (list (ret t)) expected))]
|
||||||
;; otherwise ...
|
;; otherwise ...
|
||||||
[_ #f])
|
[_ #f])
|
||||||
[(tc-result1: t) (ret (Un (-val #f) t))]
|
[(tc-result1: t) (ret (Un (-val (attribute m.default)) t))]
|
||||||
;; if it's not a ListDots, defer to the regular function typechecking
|
;; if it's not a ListDots, defer to the regular function typechecking
|
||||||
;; TODO fix double typechecking
|
;; TODO fix double typechecking
|
||||||
[_ (tc/app-regular #'form expected)])))
|
[_ (tc/app-regular #'form expected)])))
|
||||||
|
|
|
@ -2978,6 +2978,15 @@
|
||||||
#:ret (ret (-polydots (a ...) (->... (list) (a a) (-values-dots (list (t:-> -Symbol -Symbol)) a 'a))))
|
#:ret (ret (-polydots (a ...) (->... (list) (a a) (-values-dots (list (t:-> -Symbol -Symbol)) a 'a))))
|
||||||
#:expected (ret (-polydots (a ...) (->... (list) (a a) (-values-dots (list (t:-> -Symbol -Symbol)) a 'a))))]
|
#:expected (ret (-polydots (a ...) (->... (list) (a a) (-values-dots (list (t:-> -Symbol -Symbol)) a 'a))))]
|
||||||
|
|
||||||
|
[tc-err
|
||||||
|
(lambda xs (andmap (lambda: ([x : (Vectorof Any)]) x) xs))
|
||||||
|
#:ret (ret (-polydots (a ...) (->... (list) ((-vec a) a) (t:Un (-val #f) (-vec Univ)))))
|
||||||
|
#:expected (ret (-polydots (a ...) (->... (list) ((-vec a) a) (t:Un (-val #f) (-vec Univ)))))]
|
||||||
|
[tc-err
|
||||||
|
(lambda xs (andmap (lambda: ([x : #f]) x) xs))
|
||||||
|
#:ret (ret (-polydots (a ...) (->... (list) ((-val #f) a) (-val #f))))
|
||||||
|
#:expected (ret (-polydots (a ...) (->... (list) ((-val #f) a) (-val #f))))]
|
||||||
|
|
||||||
)
|
)
|
||||||
(test-suite
|
(test-suite
|
||||||
"tc-literal tests"
|
"tc-literal tests"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user