`reverse' is special on all tuples

svn: r17612

original commit: 81e963bd465ed66018506002a3b9a18f9c648493
This commit is contained in:
Sam Tobin-Hochstadt 2010-01-11 22:13:22 +00:00
parent 62d3dc1466
commit 2022bc7b80
2 changed files with 9 additions and 4 deletions

View File

@ -563,15 +563,20 @@
(ret (foldr make-Pair last tys)))]
;; special case for `reverse' to propogate expected type info
[(#%plain-app reverse arg)
#:when expected
(match expected
[(tc-result1: (Listof: _))
(tc-expr/check #'arg expected)]
[(tc-result1: (List: ts))
(tc-expr/check #'arg (ret (-Tuple (reverse ts))))
expected]
[_
(tc/funapp #'reverse #'(arg) (single-value #'reverse) (list (single-value #'arg)) expected)])]
[_
(match (single-value #'arg)
[(tc-result1: (List: ts))
(if expected
(check-below (ret (-Tuple (reverse ts))) expected)
(ret (-Tuple (reverse ts))))]
[arg-ty
(tc/funapp #'reverse #'(arg) (single-value #'reverse) (list arg-ty) expected)])])]
;; inference for ((lambda
[(#%plain-app (#%plain-lambda (x ...) . body) args ...)
#:fail-unless (= (length (syntax->list #'(x ...)))

View File

@ -60,7 +60,7 @@
(lambda (stx)
(syntax-parse stx
[(_ elem-pats)
#'(app untuple elem-pats)])))
#'(app untuple (? values elem-pats))])))
(d/c (-result t [f -no-lfilter] [o -no-lobj])