From e9c224d095a6f7ec4cf34e7eca90d1252aa66040 Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Fri, 24 Feb 2012 20:25:13 -0500 Subject: [PATCH] Pass temporary value for `Un' along in recursive call in `substitute'. Closes PR 12600. original commit: 678941ce5aaf52a9ca62ba6270a89c892b85b516 --- collects/tests/typed-racket/unit-tests/subtype-tests.rkt | 8 +++++++- collects/typed-racket/types/substitute.rkt | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/collects/tests/typed-racket/unit-tests/subtype-tests.rkt b/collects/tests/typed-racket/unit-tests/subtype-tests.rkt index 2b27f43a..7e2887ba 100644 --- a/collects/tests/typed-racket/unit-tests/subtype-tests.rkt +++ b/collects/tests/typed-racket/unit-tests/subtype-tests.rkt @@ -1,7 +1,7 @@ #lang scheme/base (require "test-utils.rkt" - (types subtype convenience union) + (types subtype convenience union utils abbrev) (rep type-rep) (env init-envs type-env-structs) (r:infer infer infer-dummy) @@ -24,6 +24,10 @@ (infer-param infer) + +(define t1 (-mu T (-lst (Un (-v a) T)))) +(define t2 (unfold t1)) + (define (subtype-tests) (subtyping-tests ;; trivial examples @@ -53,6 +57,8 @@ [(-mu x (Un -Number (make-Listof x))) (-mu y (Un -Number -Symbol (make-Listof y)))] ;; a hard one [(-mu x (*Un -Number (-pair x (-pair -Symbol (-pair x (-val null)))))) -Sexp] + [t1 (unfold t1)] + [(unfold t1) t1] ;; simple function types ((Univ . -> . -Number) (-Number . -> . Univ)) [(Univ Univ Univ . -> . -Number) (Univ Univ -Number . -> . -Number)] diff --git a/collects/typed-racket/types/substitute.rkt b/collects/typed-racket/types/substitute.rkt index f3f54d31..e2ba4cd1 100644 --- a/collects/typed-racket/types/substitute.rkt +++ b/collects/typed-racket/types/substitute.rkt @@ -33,7 +33,7 @@ ;; substitute : Type Name Type -> Type (define/cond-contract (substitute image name target #:Un [Un (get-union-maker)]) ((Type/c symbol? Type?) (#:Un procedure?) . ->* . Type?) - (define (sb t) (substitute image name t)) + (define (sb t) (substitute image name t #:Un Un)) (if (hash-ref (free-vars* target) name #f) (type-case (#:Type sb #:Filter (sub-f sb) #:Object (sub-o sb)) target