Add more hacky things to make with-handlers typecheck.
Closes PR12644. original commit: 714f667cf1758c31560fa25b5a21b5df2c17e2e0
This commit is contained in:
parent
02c4f0dd11
commit
5fbd396787
23
collects/tests/typed-racket/succeed/pr12644.rkt
Normal file
23
collects/tests/typed-racket/succeed/pr12644.rkt
Normal file
|
@ -0,0 +1,23 @@
|
|||
#lang typed/racket
|
||||
|
||||
(define-type inf (Rec inf (Any -> inf)))
|
||||
(: f inf)
|
||||
(define (f x) f)
|
||||
|
||||
(: g (All (x) (x -> x)))
|
||||
(define (g x) x)
|
||||
|
||||
(: v (Listof (U inf Byte)))
|
||||
(define v
|
||||
(list
|
||||
(with-handlers ((void values)) 2)
|
||||
(with-handlers ((void add1)) 3)
|
||||
(with-handlers ((void f)) 4)
|
||||
(with-handlers ((void g)) 5)))
|
||||
|
||||
|
||||
(list
|
||||
(with-handlers ((void values)) 6)
|
||||
(with-handlers ((void add1)) 7)
|
||||
(with-handlers ((void f)) 8)
|
||||
(with-handlers ((void g)) 9))
|
|
@ -6,7 +6,7 @@
|
|||
racket/match
|
||||
"signatures.rkt" "tc-metafunctions.rkt"
|
||||
"tc-funapp.rkt" "tc-subst.rkt"
|
||||
(types utils abbrev union subtype)
|
||||
(types utils abbrev union subtype resolve)
|
||||
(utils tc-utils)
|
||||
(rep type-rep))
|
||||
|
||||
|
@ -42,10 +42,15 @@
|
|||
;; The result of applying the function to a single argument of type (Un)
|
||||
;; FIXME: (Un) is the wrong type, see above fixme
|
||||
(define (get-result-ty t)
|
||||
(match t
|
||||
[(tc-result1: (Function: _))
|
||||
(tc/funapp #'here #'(here) t (list (ret (Un))) #f)]
|
||||
[_ (int-err "Unsupported function type in get-result-ty: \n~a" t)]))
|
||||
(let loop ((t t))
|
||||
(match t
|
||||
[(Function: _)
|
||||
(tc/funapp #'here #'(here) (ret t) (list (ret (Un))) #f)]
|
||||
[(? needs-resolving? t)
|
||||
(loop (resolve t))]
|
||||
[(or (Poly: ns _) (PolyDots: (list ns ... _) _))
|
||||
(loop (instantiate-poly t (map (λ (n) Univ) ns)))]
|
||||
[_ (int-err "Unsupported function type in get-result-ty: \n~a" t)])))
|
||||
(let loop ([form form])
|
||||
(parameterize ([current-orig-stx form])
|
||||
(syntax-parse form
|
||||
|
@ -59,10 +64,8 @@
|
|||
#:when (syntax-property form 'typechecker:exn-handler)
|
||||
(let ([t (single-value form)])
|
||||
(match t
|
||||
[(tc-result1: (Function: _))
|
||||
(set! handler-tys (cons (get-result-ty t) handler-tys))]
|
||||
[(tc-results: t)
|
||||
(tc-error "Exception handler must be a function, got \n~a" t)]))]
|
||||
[(tc-result1: t)
|
||||
(set! handler-tys (cons (get-result-ty t) handler-tys))]))]
|
||||
[stx
|
||||
;; this is the body of the with-handlers
|
||||
#:when (syntax-property form 'typechecker:exn-body)
|
||||
|
|
Loading…
Reference in New Issue
Block a user