diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-let-unit.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-let-unit.rkt index ea3a5612..69f5ad20 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-let-unit.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-let-unit.rkt @@ -8,7 +8,7 @@ global-env type-env-structs scoped-tvar-env) (rep type-rep filter-rep) syntax/free-vars - (typecheck signatures tc-metafunctions internal-forms) + (typecheck signatures tc-metafunctions tc-subst internal-forms) (utils tarjan) racket/match (contract-req) racket/list diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-metafunctions.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-metafunctions.rkt index bd5209f2..d1cb68db 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-metafunctions.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-metafunctions.rkt @@ -12,9 +12,6 @@ combine-props tc-results->values) -(provide/cond-contract - [replace-names (-> (listof (list/c identifier? Object?)) tc-results/c tc-results/c)]) - ;; abstract-results ;; @@ -240,9 +237,3 @@ [(Bot:) (set-box! flag #f) (values derived-props derived-atoms)] [_ (loop (cons p derived-props) derived-atoms (cdr worklist))]))))) -;; replace-names: (listof (list/c identifier? Object?) tc-results? -> tc-results? -;; For each name replaces all uses of it in res with the corresponding object. -;; This is used so that names do not escape the scope of their definitions -(define (replace-names names+objects res) - (for/fold ([res res]) ([name/object (in-list names+objects)]) - (subst-tc-results res (first name/object) (second name/object) #t))) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-subst.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-subst.rkt index 0c4c8a95..7b23bac7 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-subst.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-subst.rkt @@ -4,12 +4,15 @@ ;; figure 8, pg 8 of "Logical Types for Untyped Languages" (require "../utils/utils.rkt" - racket/match + racket/match racket/list (contract-req) (except-in (types abbrev utils filter-ops) -> ->* one-of/c) (rep type-rep object-rep filter-rep rep-utils)) -(provide (all-defined-out)) +(provide open-Result add-scope values->tc-results) + +(provide/cond-contract + [replace-names (-> (listof (list/c identifier? Object?)) tc-results/c tc-results/c)]) ;; Substitutes the given objects into the type, filters, and object ;; of a Result for function application. This matches up to the substitutions @@ -25,6 +28,13 @@ (subst-filter-set fs key o #t arg-ty) (subst-object old-obj key o #t)))) +;; replace-names: (listof (list/c identifier? Object?) tc-results? -> tc-results? +;; For each name replaces all uses of it in res with the corresponding object. +;; This is used so that names do not escape the scope of their definitions +(define (replace-names names+objects res) + (for/fold ([res res]) ([name/object (in-list names+objects)]) + (subst-tc-results res (first name/object) (second name/object) #t))) + ;; Substitution of objects into a tc-results (define/cond-contract (subst-tc-results res k o polarity) (-> full-tc-results/c name-ref/c Object? boolean? full-tc-results/c)