diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-app-helper.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-app-helper.rkt index f847c080..5f2f7f86 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-app-helper.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-app-helper.rkt @@ -1,7 +1,7 @@ #lang racket/base (require "../utils/utils.rkt" - racket/match unstable/list unstable/sequence racket/set + racket/match unstable/list unstable/sequence racket/set racket/list syntax/stx (only-in srfi/1 unzip4) (only-in racket/list make-list) (contract-req) @@ -39,29 +39,29 @@ [a (in-syntax args-stx)] [arg-t (in-list t-a)]) (parameterize ([current-orig-stx a]) (check-below arg-t dom-t)))) - (let* ([dom-count (length dom)] - [arg-count (+ dom-count (if rest 1 0) (length kws))]) + (let* ([dom-count (length dom)]) + ;; Currently do nothing with rest args and keyword args as there are no support for them in + ;; objects yet. (let-values ([(o-a t-a) (for/lists (os ts) - ([nm (in-range arg-count)] + ([nm (in-range dom-count)] [oa (in-sequence-forever (in-list o-a) -empty-obj)] - [ta (in-sequence-forever (in-list t-a) -Bottom)]) - (values (if (>= nm dom-count) -empty-obj oa) - ta))]) + [ta (in-sequence-forever (in-list t-a) #f)]) + (values oa ta))]) (match rng - ((AnyValues:) tc-any-results) - ((Values: results) + [(AnyValues:) tc-any-results] + [(Values: results) (define-values (t-r f-r o-r) (for/lists (t-r f-r o-r) ([r (in-list results)]) (open-Result r o-a t-a))) - (ret t-r f-r o-r)) - ((ValuesDots: results dty dbound) + (ret t-r f-r o-r)] + [(ValuesDots: results dty dbound) (define-values (t-r f-r o-r) (for/lists (t-r f-r o-r) ([r (in-list results)]) (open-Result r o-a t-a))) - (ret t-r f-r o-r dty dbound)))))] + (ret t-r f-r o-r dty dbound)])))] ;; this case should only match if the function type has mandatory keywords ;; but no keywords were provided in the application [((arr: _ _ _ _ diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-subst.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-subst.rkt index 52bc7575..79edd3f9 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-subst.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-subst.rkt @@ -18,7 +18,7 @@ ;; of a Result for function application. This matches up to the substitutions ;; in the T-App rule from the ICFP paper. (define/cond-contract (open-Result r objs [ts #f]) - (->* (Result? (listof Object?)) ((listof Type/c)) (values Type/c FilterSet? Object?)) + (->* (Result? (listof Object?)) ((listof (or/c #f Type/c))) (values Type/c FilterSet? Object?)) (match-define (Result: t fs old-obj) r) (for/fold ([t t] [fs fs] [old-obj old-obj]) ([(o arg) (in-indexed (in-list objs))] @@ -32,7 +32,7 @@ ;; This is essentially ψ+|ψ- [o/x] from the paper (define/cond-contract (subst-filter-set fs k o polarity [t #f]) (->* ((or/c FilterSet? NoFilter?) name-ref/c Object? boolean?) ((or/c #f Type/c)) FilterSet?) - (define extra-filter (if t (make-TypeFilter t null k) -top)) + (define extra-filter (if t (-filter t k) -top)) (define (add-extra-filter f) (define f* (-and extra-filter f)) (match f* diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt index 2b61b084..1f81f11c 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt @@ -879,7 +879,7 @@ #:ret (ret -Number)] [tc-err (call-with-values 5 (lambda: ([x : Number] [y : Number]) (+ x y))) - #:ret (ret -Number)] + #:ret (ret -Number -bot-filter)] [tc-err (call-with-values (lambda () (values 2)) 5)] [tc-err (call-with-values (lambda () (values 2 1)) @@ -2737,6 +2737,16 @@ (if (number? x) (add1 x) 0)) -Bottom] + [tc-err + (let ([f (lambda (x y) y)]) + (f 1)) + #:ret (ret Univ -top-filter)] + + [tc-err + (let ([f (lambda (x y) y)]) + (f 1 2 3)) + #:ret (ret Univ -true-filter)] + ) (test-suite "tc-literal tests"