diff --git a/typed-racket-lib/typed-racket/base-env/base-env.rkt b/typed-racket-lib/typed-racket/base-env/base-env.rkt index b0d4ec9e..f8de6bd8 100644 --- a/typed-racket-lib/typed-racket/base-env/base-env.rkt +++ b/typed-racket-lib/typed-racket/base-env/base-env.rkt @@ -1390,8 +1390,18 @@ [semaphore-wait/enable-break (-> -Semaphore -Void)] [semaphore-peek-evt (-> -Semaphore (-mu x (-evt x)))] [semaphore-peek-evt? (asym-pred Univ B (-FS (-filter (-mu x (-evt x)) 0) -top))] -;[call-with-semaphore ???] -;[call-with-semaphore/enable-break ???] +[call-with-semaphore + (-polydots (b a) + (cl->* (->... (list -Semaphore (->... '() [a a] b)) + [a a] b) + (->... (list -Semaphore (->... '() [a a] b) (-opt (-> b))) + [a a] b)))] +[call-with-semaphore/enable-break + (-polydots (b a) + (cl->* (->... (list -Semaphore (->... '() [a a] b)) + [a a] b) + (->... (list -Semaphore (->... '() [a a] b) (-opt (-> b))) + [a a] b)))] ;; Section 11.3.1 (Thread Cells) [thread-cell? (make-pred-ty (make-ThreadCellTop))] diff --git a/typed-racket-test/unit-tests/typecheck-tests.rkt b/typed-racket-test/unit-tests/typecheck-tests.rkt index 52fef588..2ad9ba71 100644 --- a/typed-racket-test/unit-tests/typecheck-tests.rkt +++ b/typed-racket-test/unit-tests/typecheck-tests.rkt @@ -1840,6 +1840,20 @@ (tc-e (make-semaphore) -Semaphore) (tc-e (let: ((s : Semaphore (make-semaphore 3))) (semaphore-post s)) -Void) + [tc-e (call-with-semaphore (make-semaphore) + (lambda: ([x : String]) (void)) + (lambda: () "x") + "a") + (t:Un -String -Void)] + [tc-err (call-with-semaphore (make-semaphore) + (lambda: ([x : String]) (void)))] + [tc-err (call-with-semaphore (make-semaphore) + (lambda: ([x : String]) (void)) + #f 'x)] + [tc-err (call-with-semaphore (make-semaphore) + (lambda: ([x : String]) (void)) + 'not-a-failure-thunk + "x")] ;Random Numbers (tc-e (make-pseudo-random-generator) -Pseudo-Random-Generator)