From d664ee1430302e225e77b9cfc546e819a7983c3f Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Thu, 12 Jun 2014 23:50:10 -0500 Subject: [PATCH] change recursive-contract to reject cyclic values For a few reasons: - this seems to fit better with how TR already works - cyclic values are something that, at least in my experience, abstractions are not generally equipped to handle (and, perhaps worse, don't seem all that useful when weighed against the non-termination problems that can come up) - there was a suspicious case in the projection where, when a cycle was detected the projection just returned its argument (the place in the diff for this commit where there is now a call to raise-blame-error). I couldn't get this to cause problems, but this might just be because I'm not smart enough related to PR 14559 --- .../racket-test/tests/racket/contract/recursive-contract.rkt | 2 +- racket/collects/racket/contract/private/base.rkt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/racket-pkgs/racket-test/tests/racket/contract/recursive-contract.rkt b/pkgs/racket-pkgs/racket-test/tests/racket/contract/recursive-contract.rkt index 437dcc087c..7cd12ca654 100644 --- a/pkgs/racket-pkgs/racket-test/tests/racket/contract/recursive-contract.rkt +++ b/pkgs/racket-pkgs/racket-test/tests/racket/contract/recursive-contract.rkt @@ -74,7 +74,7 @@ (letrec ([doll-ctc2 (or/c 'center (struct/c doll (recursive-contract doll-ctc2 #:flat)))]) (contract doll-ctc2 (doll 4) 'pos 'neg)))) - (test/spec-passed + (test/pos-blame 'recursive-contract12 '(let () (define c diff --git a/racket/collects/racket/contract/private/base.rkt b/racket/collects/racket/contract/private/base.rkt index 954eb82cf8..40427fd47f 100644 --- a/racket/collects/racket/contract/private/base.rkt +++ b/racket/collects/racket/contract/private/base.rkt @@ -144,7 +144,8 @@ => (λ (ht) (cond - [(hash-ref ht val #f) val] + [(hash-ref ht val #f) + (raise-blame-error blame val '(given: "a value with a cycle"))] [else (hash-set! ht val #t) ((orig-projection blame) val)]))] @@ -158,7 +159,7 @@ => (λ (ht) (cond - [(hash-ref ht val #f) #t] + [(hash-ref ht val #f) #f] [else (hash-set! ht val #t) (orig-first-order val)]))]