Pass temporary value for Un' along in recursive call in substitute'.

Closes PR 12600.

original commit: 678941ce5aaf52a9ca62ba6270a89c892b85b516
This commit is contained in:
Sam Tobin-Hochstadt 2012-02-24 20:25:13 -05:00
parent be78fbfeb2
commit e9c224d095
2 changed files with 8 additions and 2 deletions

View File

@ -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)]

View File

@ -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