diff --git a/collects/typed-scheme/test2.ss b/collects/typed-scheme/test2.ss index 860a39efa0..779f389a5e 100644 --- a/collects/typed-scheme/test2.ss +++ b/collects/typed-scheme/test2.ss @@ -44,4 +44,6 @@ (map + (list 1 2 3)) (map + (list 1 2 3) (list 1 2 3)) ;; error -;(map + (list 1 2 3) (list 1 2 "foo")) \ No newline at end of file +;(map + (list 1 2 3) (list 1 2 "foo")) + +((lambda (a b . c) (+ a b (car c))) 1 2 3 4) \ No newline at end of file diff --git a/collects/typed-scheme/typecheck/tc-app.ss b/collects/typed-scheme/typecheck/tc-app.ss index 16e7d2d618..6ea9bf03c3 100644 --- a/collects/typed-scheme/typecheck/tc-app.ss +++ b/collects/typed-scheme/typecheck/tc-app.ss @@ -3,7 +3,7 @@ (require (rename-in "../utils/utils.ss" [infer r:infer]) "signatures.ss" "tc-metafunctions.ss" "tc-app-helper.ss" - stxclass scheme/match mzlib/trace + stxclass scheme/match mzlib/trace scheme/list (for-syntax stxclass scheme/base) (types utils abbrev union subtype resolve) (utils tc-utils) @@ -64,11 +64,20 @@ (tc/let-values #'((x) ...) #'(args ...) #'body #'(let-values ([(x) args] ...) . body) expected)] + ;; inference for ((lambda with dotted rest + [(#%plain-app (#%plain-lambda (x ... . rst:id) . body) args ...) + #:when (<= (length (syntax->list #'(x ...))) + (length (syntax->list #'(args ...)))) + (let-values ([(fixed-args varargs) (split-at (syntax->list #'(args ...)) (length (syntax->list #'(x ...))))]) + (with-syntax ([(fixed-args ...) fixed-args] + [varg #`(#%plain-app list #,@varargs)]) + (tc/let-values #'((x) ... (rst)) #`(fixed-args ... varg) #'body + #'(let-values ([(x) fixed-args] ... [(rst) varg]) . body) + expected)))] [(#%plain-app f . args) (let* ([f-ty (single-value #'f)] [arg-tys (map single-value (syntax->list #'args))]) - (tc/funapp #'f #'args f-ty arg-tys expected))] - [_ (int-err "tc/app NYI")])) + (tc/funapp #'f #'args f-ty arg-tys expected))])) ;(trace tc/app/internal)