typed-racket/typed-racket-test/fail/poly-struct-mutable-parent.rkt
Asumu Takikawa 43dc59bea2 Restrict struct predicate when parent is mutable
Correctly restrict the struct predicate's filter type when
a parent struct is mutable but the child is not and they both
have polymorphic type variables.

See the discussion in GH issue #205
2016-05-20 16:56:49 -04:00

21 lines
360 B
Racket

#lang typed/racket
;; The call to `set-foo-x!` below should fail because the
;; predicate filter on `bar?` has to be restrictive.
(struct (A) foo ([x : A]) #:mutable)
(struct (A) baz foo ())
(define (f [i : Integer]) : (foo Integer)
(baz i))
(: x (foo Integer))
(define x (f 1))
(: y Any)
(define y x)
(if (baz? y) (set-foo-x! y "foo") 2)
(foo-x x)