From 6cc10cdb181e88a8fd1bc2958314c44e086fe8e3 Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Sun, 18 May 2014 15:03:28 -0700 Subject: [PATCH] Remove unused code in subst-gen, and remove internal error. --- .../typed-racket/infer/infer-unit.rkt | 45 +++++-------------- .../typed-racket/unit-tests/infer-tests.rkt | 4 +- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/infer/infer-unit.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/infer/infer-unit.rkt index e977fd510b..a02b9df0da 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/infer/infer-unit.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/infer/infer-unit.rkt @@ -716,39 +716,18 @@ ;; was found. If we're at this point and had no other constraints, then adding the ;; equivalent of the constraint (dcon null (c Bot X Top)) is okay. (define (extend-idxs S) - (define fi-R (fi R)) - ;; If the index variable v is not used in the type, then - ;; we allow it to be replaced with the empty list of types; - ;; otherwise we error, as we do not yet know what an appropriate - ;; lower bound is. - (define (demote/check-free v) - (if (memq v fi-R) - (int-err "attempted to demote dotted variable") - (i-subst null))) - ;; absent-entries is #f if there's an error in the substitution, otherwise - ;; it's a list of variables that don't appear in the substitution - (define absent-entries - (for/fold ([no-entry null]) ([v (in-list Y)]) - (let ([entry (hash-ref S v #f)]) - ;; Make sure we got a subst entry for an index var - ;; (i.e. a list of types for the fixed portion - ;; and a type for the starred portion) - (cond - [(not no-entry) no-entry] - [(not entry) (cons v no-entry)] - [(or (i-subst? entry) (i-subst/starred? entry) (i-subst/dotted? entry)) no-entry] - [else #f])))) - (and absent-entries - (hash-union - (for/hash ([missing (in-list absent-entries)]) - (let ([var (hash-ref idx-hash missing Constant)]) - (values missing - (evcase var - [Constant (demote/check-free missing)] - [Covariant (demote/check-free missing)] - [Contravariant (i-subst/starred null Univ)] - [Invariant (demote/check-free missing)])))) - S))) + (hash-union + (for/hash ([v (in-list Y)] + #:unless (hash-has-key? S v)) + (let ([var (hash-ref idx-hash v Constant)]) + (values v + (evcase var + [Constant (i-subst null)] + [Covariant (i-subst null)] + [Contravariant (i-subst/starred null Univ)] + ;; TODO figure out if there is a better subst here + [Invariant (i-subst null)])))) + S)) (match (car (cset-maps C)) [(cons cmap (dmap dm)) (let ([subst (hash-union diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/infer-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/infer-tests.rkt index 71734745ae..4c36f491b4 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/infer-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/infer-tests.rkt @@ -109,9 +109,7 @@ (infer-t (-v a) (-v b) #:vars '(b)) (infer-t (make-ListDots -Symbol 'b) (-lst -Symbol) #:indices '(b) - ;; TODO Figure out why this doesnt' work - #;#; - #:result [(make-ListDots (-v b) 'b) (-lst Univ)]) + #:result [(make-ListDots (-v b) 'b) -Null]) (infer-t (make-ListDots (-v a) 'b) (-lst -Symbol) #:vars '(a) #:indices '(b) #:result [(-lst* (make-ListDots (-v b) 'b) (-v a)) (-lst* (-lst -Bottom) -Bottom)])