diff --git a/collects/tests/typed-racket/fail/mandatory-kw.rkt b/collects/tests/typed-racket/fail/mandatory-kw.rkt new file mode 100644 index 0000000000..a388301c4e --- /dev/null +++ b/collects/tests/typed-racket/fail/mandatory-kw.rkt @@ -0,0 +1,11 @@ +#; +(exn:pred (lambda (e) (regexp-match? "Type Checker" e))) +#lang typed/racket + +;; This should raise a type error and not an internal error + +(: f (#:foo False -> False)) +(define (f #:foo foo) foo) + +;; bad call that's missing a mandatory keyword +(f) diff --git a/collects/typed-racket/typecheck/tc-app-helper.rkt b/collects/typed-racket/typecheck/tc-app-helper.rkt index bb3eca8ea9..aa66a760e7 100644 --- a/collects/typed-racket/typecheck/tc-app-helper.rkt +++ b/collects/typed-racket/typecheck/tc-app-helper.rkt @@ -44,6 +44,18 @@ ([r (in-list results)]) (open-Result r o-a t-a))) (ret t-r f-r o-r)))] + ;; this case should only match if the function type has mandatory keywords + ;; but no keywords were provided in the application + [((arr: _ _ _ _ + ;; at least one mandatory keyword + (app (λ (kws) + (for/or ([keyword kws]) + (match keyword + [(Keyword: kw _ #t) kw] + [_ #f]))) + (? values req-kw))) _) + (when check? + (tc-error "Required keyword not supplied: ~a" req-kw))] [((arr: _ _ _ drest '()) _) (int-err "funapp with drest args ~a ~a NYI" drest argtys)] [((arr: _ _ _ _ kws) _)