check for free-vars in types of casted-exprs (#384)
This commit is contained in:
parent
39d6a6047a
commit
e3f56c8a25
|
@ -343,13 +343,17 @@
|
|||
(define existing-ty-ctc (syntax-local-lift-expression
|
||||
(make-contract-def-rhs/from-typed existing-ty-id #f #f)))
|
||||
(define (store-existing-type existing-type)
|
||||
(check-no-free-vars existing-type #'v)
|
||||
(cast-table-set! existing-ty-id (datum->syntax #f existing-type #'v)))
|
||||
(define (check-valid-type _)
|
||||
(define type (parse-type #'ty))
|
||||
(check-no-free-vars type #'ty))
|
||||
(define (check-no-free-vars type stx)
|
||||
(define vars (fv type))
|
||||
;; If there was an error don't create another one
|
||||
(unless (or (Error? type) (null? vars))
|
||||
(tc-error/delayed
|
||||
#:stx stx
|
||||
"Type ~a could not be converted to a contract because it contains free variables."
|
||||
type)))
|
||||
#`(#,(external-check-property #'#%expression check-valid-type)
|
||||
|
|
11
typed-racket-test/fail/cast-tyvar.rkt
Normal file
11
typed-racket-test/fail/cast-tyvar.rkt
Normal file
|
@ -0,0 +1,11 @@
|
|||
#;
|
||||
(exn-pred exn:fail:syntax?
|
||||
#rx"Type \\(List X\\) could not be converted to a contract"
|
||||
#rx"contains free variables"
|
||||
#rx"10.8")
|
||||
|
||||
#lang typed/racket
|
||||
(: f : (All (X) (-> X X)))
|
||||
(define (f x)
|
||||
(cast (list x) Any)
|
||||
x)
|
Loading…
Reference in New Issue
Block a user