From 9052bb40a2686c411473d9b77479acfe6dd3a8cb Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Fri, 20 Jun 2014 12:21:45 -0400 Subject: [PATCH] Give more information for kw errors in TR Tells the user which missing keywords were mandatory and which were optional (which is useful if, e.g., the expected type says mandatory but the function had it optional). original commit: 8b53d32f5231f94677e1088b940e92a71ed1e311 --- .../typed-racket/types/kw-types.rkt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/kw-types.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/kw-types.rkt index 10e87b55..6c025acc 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/kw-types.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/kw-types.rkt @@ -264,17 +264,20 @@ (define-values (mand-kw-types opt-kw-types) (partition-kws kws)) (define mand-kws (map Keyword-kw mand-kw-types)) (define opt-kws (map Keyword-kw opt-kw-types)) - (define missing-kws (set-union (set-subtract mand-kws actual-mands) - (set-subtract opt-kws actual-opts))) + (define missing-opts (set-subtract opt-kws actual-opts)) + (define missing-mands (set-subtract mand-kws actual-mands)) ;; extra optional keywords are okay (define extra-kws (set-subtract actual-mands mand-kws)) - (unless (set-empty? missing-kws) + (unless (and (set-empty? missing-mands) + (set-empty? missing-opts)) (tc-error/fields #:delayed? #t "type mismatch" #:more "function is missing keyword arguments" - "missing keywords" - (string-join (map ~a missing-kws)) + "missing mandatory keywords" + (string-join (map ~a missing-mands)) + "missing optional keywords" + (string-join (map ~a missing-opts)) "expected type" f-type)) (unless (set-empty? extra-kws) (tc-error/fields