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
This commit is contained in:
Robby Findler 2014-06-12 23:50:10 -05:00
parent bebf41a36e
commit d664ee1430
2 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -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)]))]