Support Any wrapping for promises

Closes PR 13326
This commit is contained in:
Asumu Takikawa 2012-12-03 17:43:32 -05:00
parent ed00c8d70c
commit 0252207e38
3 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,14 @@
#;
(exn-pred exn:fail:contract?)
#lang racket
(module typed typed/racket
(: d Any)
(define d (delay (lambda: ([x : Integer]) (+ x 1))))
(provide d))
(require 'typed)
;; this line should raise a ctc error
((force d) 6)

View File

@ -0,0 +1,19 @@
#lang racket
(require rackunit)
;; the setup here is just to make it play nice with Rackunit
(check-not-exn
(λ ()
(parameterize ([current-error-port (open-output-nowhere)])
(eval
(quote
(begin
;; This is the actual test case
(module typed typed/racket
(require typed/rackunit)
;; Any wrappings should be okay here
(check-equal? (delay 0) (delay 0)))
(require 'typed)))
(make-base-namespace)))))

View File

@ -1,6 +1,7 @@
#lang racket/base
(require racket/match racket/contract/base racket/contract/combinator)
(require racket/match racket/contract/base racket/contract/combinator
racket/promise)
(define undef (letrec ([x x]) x))
@ -81,6 +82,10 @@
(chaperone-procedure v (case-lambda [() (values)]
[_ (fail v)]))
(chaperone-procedure v (lambda args (fail v))))]
[(? promise?)
;; for promises, just apply Any in the promise
(contract (promise/c any-wrap/c) v
(blame-positive b) (blame-negative b))]
[_ (fail v)]))
t)