diff --git a/collects/racket/contract/private/opters.rkt b/collects/racket/contract/private/opters.rkt index b0b1264cca..ef4a008a63 100644 --- a/collects/racket/contract/private/opters.rkt +++ b/collects/racket/contract/private/opters.rkt @@ -633,7 +633,17 @@ (chaperone-procedure val (make-keyword-procedure - (λ (kwds kwd-args . regular-args) (raise-blame-error '...)) + (λ (kwds kwd-args . regular-args) + (raise-blame-error (blame-swap blame) + val + '(expected: "no keyword arguments" given: "~a") + (apply string-append + (let loop ([kwds kwds]) + (cons + (format "~a" (car kwds)) + (cond + [(null? (cdr kwds)) '()] + [else (cons " " (loop (cdr kwds)))])))))) exact-proc))) (define (raise-flat-arrow-err blame val n) diff --git a/collects/tests/racket/contract-test.rktl b/collects/tests/racket/contract-test.rktl index bfe828b17f..f46064d94f 100644 --- a/collects/tests/racket/contract-test.rktl +++ b/collects/tests/racket/contract-test.rktl @@ -1120,6 +1120,30 @@ 'pos 'neg) 1)) + + (test/neg-blame + 'contract-arrow-keyword17 + '((contract (-> integer? integer?) + (λ (x #:y [y #f]) x) + 'pos + 'neg) + #f)) + + (test/pos-blame + 'contract-arrow-keyword18 + '((contract (-> integer? integer?) + (λ (x #:y [y #f]) y) + 'pos + 'neg) + 1)) + + (test/neg-blame + 'contract-arrow-keyword19 + '((contract (-> boolean?) + (λ (#:x [x #f]) x) + 'pos + 'neg) + #:x 1)) (test/spec-passed 'contract-arrow1