From 93def1f75305d94ea9c936cc7176b30342b3d7a0 Mon Sep 17 00:00:00 2001 From: Alexis King Date: Fri, 2 Nov 2018 11:24:39 -0500 Subject: [PATCH] Fix stream contracts to work with impersonator contracts --- pkgs/racket-doc/scribblings/reference/sequences.scrbl | 7 +++---- pkgs/racket-test/tests/racket/contract/stream.rkt | 6 +++++- racket/collects/racket/private/for.rkt | 4 +++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pkgs/racket-doc/scribblings/reference/sequences.scrbl b/pkgs/racket-doc/scribblings/reference/sequences.scrbl index 2d5477da17..a8e81bbe33 100644 --- a/pkgs/racket-doc/scribblings/reference/sequences.scrbl +++ b/pkgs/racket-doc/scribblings/reference/sequences.scrbl @@ -1266,10 +1266,9 @@ If the @racket[c] argument is a flat contract or a chaperone contract, then the result will be a chaperone contract. Otherwise, the result will be an impersonator contract. -When an @racket[stream/c] contract is applied to an asynchronous channel, -the result is not @racket[eq?] to the input. The result will be either a -@tech{chaperone} or @tech{impersonator} of the input depending on the type of -contract. +When an @racket[stream/c] contract is applied to a stream, the result is not +@racket[eq?] to the input. The result will be either a @tech{chaperone} or +@tech{impersonator} of the input depending on the type of contract. Contracts on streams are evaluated lazily by necessity (since streams may be infinite). Contract violations will not be raised until the value in violation diff --git a/pkgs/racket-test/tests/racket/contract/stream.rkt b/pkgs/racket-test/tests/racket/contract/stream.rkt index 50ea9373d1..41c7137b46 100644 --- a/pkgs/racket-test/tests/racket/contract/stream.rkt +++ b/pkgs/racket-test/tests/racket/contract/stream.rkt @@ -41,4 +41,8 @@ (test/pos-blame 'stream/c9 '(stream-first (stream-rest (contract (stream/c (and/c integer? (first-or/c 0 positive?))) - (stream 0 -1) 'pos 'neg))))) + (stream 0 -1) 'pos 'neg)))) + + (test/spec-passed + 'stream/impersonator-ctc + '(contract (stream/c (make-contract #:first-order (lambda (x) #t))) empty-stream 'pos 'neg))) diff --git a/racket/collects/racket/private/for.rkt b/racket/collects/racket/private/for.rkt index 72c0400a2a..3fd3155ddf 100644 --- a/racket/collects/racket/private/for.rkt +++ b/racket/collects/racket/private/for.rkt @@ -421,7 +421,9 @@ " (procedure-arity-includes/c 1)\n" " (procedure-arity-includes/c 1))") v)) - (vector->immutable-vector v)))) + (vector->immutable-vector v)) + '() + #t)) ;; new-style sequence property, where the property value is a procedure ;; to get the sequence-driving value and procedures;