From 4d94ef91cf841b40e5272a5f4c5e9158fddba300 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sat, 8 Mar 2014 15:41:05 -0600 Subject: [PATCH] allow 'contract' to use #f for the positive name, but still disallow #f at the blame record level closes PR 14387 --- .../racket-test/tests/racket/contract/blame.rkt | 3 +++ racket/collects/racket/contract/private/base.rkt | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pkgs/racket-pkgs/racket-test/tests/racket/contract/blame.rkt b/pkgs/racket-pkgs/racket-test/tests/racket/contract/blame.rkt index 7c894aa6d7..5840354c41 100644 --- a/pkgs/racket-pkgs/racket-test/tests/racket/contract/blame.rkt +++ b/pkgs/racket-pkgs/racket-test/tests/racket/contract/blame.rkt @@ -48,6 +48,9 @@ [rename five chaperone-five chaperone-blame-ok/c] [rename five flat-five flat-blame-ok/c])))) + (test/no-error + '(contract string? "string" #f 'neg)) + (begin (test/no-error '(dynamic-require ''blame-ok-dynamic 'impersonator-five)) diff --git a/racket/collects/racket/contract/private/base.rkt b/racket/collects/racket/contract/private/base.rkt index c6aa35bf76..eec1b49b63 100644 --- a/racket/collects/racket/contract/private/base.rkt +++ b/racket/collects/racket/contract/private/base.rkt @@ -53,7 +53,15 @@ (make-blame (build-source-location loc) name (λ () (contract-name c)) - pos + + ;; hack! We need to allow pos = #f for backwards + ;; compatibility, but we cannot put #f into the + ;; blame struct now because #f means that the + ;; name is not known. Since #f is not a very good + ;; name, we'll just put something stupid here + ;; instead of changing the library around. + (or pos "false") + (if cvfp #f neg) #t)) (define new-val