From 533c31949676f8a64f8ae6cace5778387a79f6b3 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 28 Jan 2014 11:44:33 -0500 Subject: [PATCH] =?UTF-8?q?Handle=20kw=20=CE=BBs=20when=20useful=20annotat?= =?UTF-8?q?ions=20are=20missing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes PR 14322 original commit: 7476ca0ac067a58f606f3d49ede69e09fcbc9c58 --- .../typed-racket/typecheck/tc-expr-unit.rkt | 6 +++--- .../tests/typed-racket/unit-tests/typecheck-tests.rkt | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt index cf45102d..580c837f 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt @@ -273,10 +273,10 @@ (match expected [(tc-result1: (and f (or (Function: _) (Poly: _ (Function: _))))) - (tc-expr/check/type #'fun (kw-convert f #:split #t))] + (tc-expr/check/type #'fun (kw-convert f #:split #t)) + expected] [(or (tc-results: _) (tc-any-results:)) - (tc-error/expr "Keyword functions must have function type, given ~a" expected)]) - expected] + (tc-expr (remove-ascription form))])] ;; opt function def [(~and (let-values ([(f) fun]) . body) opt:opt-lambda^) (define conv-type 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 fc72932a..4203c2e4 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 @@ -1981,6 +1981,10 @@ [tc-err (let () (tr:define (f #{x : Symbol} #:y y) y) (f "a" #:y 'b)) #:msg #rx"expected: Symbol.*given: String"] |# + [tc-e (tr:lambda (x #:y y) y) (->key Univ #:y Univ #t Univ)] + [tc-e ((tr:lambda (x #:y y) y) 'a #:y 'b) Univ] + [tc-e ((tr:lambda (x #:y y . args) y) 'a #:y 'b) Univ] + [tc-e ((tr:lambda (x #:y [y 'y] . args) y) 'a #:y 'b) Univ] [tc-err (let () (tr:define (f x #:y y) (string-append x "foo")) (void)) #:msg #rx"expected: String.*given: Any"] [tc-err (let () (tr:define (f x #:y y) y) (f "a"))