diff --git a/pkgs/racket-test/tests/racket/contract/class.rkt b/pkgs/racket-test/tests/racket/contract/class.rkt index 52f579cfe9..23bf7f5f86 100644 --- a/pkgs/racket-test/tests/racket/contract/class.rkt +++ b/pkgs/racket-test/tests/racket/contract/class.rkt @@ -2459,7 +2459,22 @@ 'pos 'neg))]) (object=? (send o get-this) o)) #t) - + + (test/spec-passed/result + 'keywords-in-error-message1 + '(with-handlers ([exn:fail:contract:blame? (λ (x) + (define m + (regexp-match #rx"given: ([^\n]*)" (exn-message x))) + (and m (list-ref m 1)))]) + (send (new (contract (class/c [save-file (-> any/c void?)]) + (class object% + (define/public (save-file #:unscaled? [x 1]) + (void)) + (super-new)) + 'pos 'neg)) + save-file #:unscaled? #t)) + "#:unscaled?") + ;; this test case won't pass until the internal-ctc ;; call is delayed in the new class/c projections ;; (but otherwise it passes) diff --git a/racket/collects/racket/contract/private/arrow.rkt b/racket/collects/racket/contract/private/arrow.rkt index 0f41b86842..c79db49402 100644 --- a/racket/collects/racket/contract/private/arrow.rkt +++ b/racket/collects/racket/contract/private/arrow.rkt @@ -420,7 +420,21 @@ (if (and (null? req-kwd) (null? opt-kwd)) (λ (kwds kwd-args . args) (raise-blame-error (blame-swap blame) val - '(expected: "no keywords"))) + (list 'expected: + "no keywords" + 'given: + (apply + string-append + (let loop ([kwds kwds]) + (cond + [(null? kwds) '()] + [(null? (cdr kwds)) + (list "#:" (keyword->string (car kwds)))] + [else + (list* "#:" + (keyword->string (car kwds)) + " " + (loop (cdr kwds)))])))))) (λ (kwds kwd-args . args) (with-continuation-mark contract-continuation-mark-key blame