From 7af943e41de8c838381f377e9e96ec0b078d9cd6 Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Sat, 10 May 2014 17:09:53 -0700 Subject: [PATCH] Handle inference of list dots under regular lists. --- .../typed-racket-lib/typed-racket/infer/infer-unit.rkt | 5 +++-- .../tests/typed-racket/unit-tests/infer-tests.rkt | 3 ++- 2 files changed, 5 insertions(+), 3 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 9de3ecd8af..eb2319459b 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 @@ -582,8 +582,9 @@ ;; ListDots can be below a Listof ;; must be above mu unfolding [((ListDots: s-dty dbound) (Listof: t-elem)) - #:return-when (memq dbound Y) #f - (cgen V X Y (substitute Univ dbound s-dty) t-elem)] + (if (memq dbound Y) + (% move-rest-to-dmap (cgen V (cons dbound X) Y s-dty t-elem) dbound) + (cgen V X Y (substitute Univ dbound s-dty) t-elem))] ;; two ListDots with the same bound, just check the element type ;; This is conservative because we don't try to infer a constraint on dbound. [((ListDots: s-dty dbound) (ListDots: t-dty dbound)) 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 691b13fc61..8f45f195e8 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 @@ -100,6 +100,8 @@ (infer-t (-v a) (-v b) #:vars '(b)) (infer-t (make-ListDots -Symbol 'b) (-lst -Symbol) #:indices '(b)) + (infer-t (make-ListDots (-v a) 'b) (-lst -Symbol) #:vars '(a) #:indices '(b)) + (infer-t (make-ListDots (-v b) 'b) (-lst -Symbol) #:indices '(b)) (infer-t (make-ListDots (-v b) 'b) (-lst Univ) #:indices '(b)) (infer-t (make-ListDots (-v a) 'b) (make-ListDots -Symbol 'b) #:vars '(a)) (infer-t (make-ListDots -Symbol 'b) (make-ListDots Univ 'b) #:indices '(b)) @@ -128,7 +130,6 @@ [infer-t (-lst* -String) (make-ListDots -Symbol 'b) #:indices '(b) #:fail] ;; Currently Broken - ;(infer-t (make-ListDots (-v b) 'b) (-lst -Symbol) #:indices '(b)) ;(infer-t (-lst -Symbol) (make-ListDots -Symbol 'b) #:indices '(b)) ;(infer-t (make-ListDots (-v b) 'b) (make-ListDots -Symbol 'b) #:indices '(b)) ;(infer-t (make-ListDots -Symbol 'b) (make-ListDots (-v b) 'b) #:indices '(b))