Skip to content

Commit 0183863

Browse files
bennnsamth
authored andcommitted
any-wrap: move channel? case before evt? case
(channel? x) implies (evt? x), so the any-wrap code that protects channels was never used --- leaving a soundness bug - move the evt? case below the channel? case - fix bugs in the channel? chaperone
1 parent 0bd9f5c commit 0183863

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

typed-racket-lib/typed-racket/utils/any-wrap.rkt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,6 @@
171171
(with-contract-continuation-mark
172172
blame+neg-party
173173
(any-wrap/traverse k neg-party seen/v))))] ;; key
174-
[(? evt?) (chaperone-evt v (lambda (e) (values e (λ (v)
175-
(with-contract-continuation-mark
176-
blame+neg-party
177-
(any-wrap/traverse v neg-party seen/v))))))]
178174
[(? set?) (chaperone-hash-set
179175
v
180176
(λ (s e) e) ; inject
@@ -208,8 +204,14 @@
208204
(chaperone-channel v
209205
(lambda (e) (with-contract-continuation-mark
210206
blame+neg-party
211-
(values v (any-wrap/traverse v neg-party seen/v))))
212-
(lambda (e) (fail neg-party v)))]
207+
(values e (lambda (inner-val) (any-wrap/traverse inner-val neg-party seen/v)))))
208+
(lambda (_e _new-val) (fail neg-party v)))]
209+
[(? evt?)
210+
;; must come after cases for write-able values that can be used as events
211+
(chaperone-evt v (lambda (e) (values e (λ (v)
212+
(with-contract-continuation-mark
213+
blame+neg-party
214+
(any-wrap/traverse v neg-party seen/v))))))]
213215
[_
214216
(on-opaque v b neg-party)]))
215217
any-wrap/traverse)

typed-racket-test/unit-tests/contract-tests.rkt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,4 +893,18 @@
893893
(t-int (-val #rx"aa") void #rx"aa" #:untyped)
894894
(t-int (-val #rx#"bb") void #rx#"bb" #:untyped)
895895

896+
(t-int -ChannelTop
897+
channel-get
898+
(let ((ch (make-channel))) (thread (λ () (channel-put ch "ok"))) ch)
899+
#:typed)
900+
(t-int -ChannelTop
901+
channel-get
902+
(let ((ch (make-channel))) (thread (λ () (channel-put ch "ok"))) ch)
903+
#:untyped)
904+
(t-int/fail -ChannelTop
905+
(lambda (ch)
906+
(channel-put ch 'error))
907+
(make-channel)
908+
#:typed
909+
#:msg "higher-order value passed as `Any`")
896910
))

0 commit comments

Comments
 (0)