Skip to content

Commit 7f400e7

Browse files
committed
Make inference work with lists under dotted lists.
1 parent 7af943e commit 7f400e7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/infer/infer-unit.rkt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,11 @@
585585
(if (memq dbound Y)
586586
(% move-rest-to-dmap (cgen V (cons dbound X) Y s-dty t-elem) dbound)
587587
(cgen V X Y (substitute Univ dbound s-dty) t-elem))]
588+
[((Listof: s-elem) (ListDots: t-dty dbound))
589+
#:return-unless (memq dbound Y) #f
590+
(define v (cgen V (cons dbound X) Y s-elem t-dty))
591+
(and v (move-rest-to-dmap v dbound #:exact #t))]
592+
588593
;; two ListDots with the same bound, just check the element type
589594
;; This is conservative because we don't try to infer a constraint on dbound.
590595
[((ListDots: s-dty dbound) (ListDots: t-dty dbound))

pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/infer-tests.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
(infer-t (make-ListDots -Symbol 'b) (-lst -Symbol) #:indices '(b))
103103
(infer-t (make-ListDots (-v a) 'b) (-lst -Symbol) #:vars '(a) #:indices '(b))
104104
(infer-t (make-ListDots (-v b) 'b) (-lst -Symbol) #:indices '(b))
105+
(infer-t (-lst -Symbol) (make-ListDots -Symbol 'b) #:indices '(b))
105106
(infer-t (make-ListDots (-v b) 'b) (-lst Univ) #:indices '(b))
106107
(infer-t (make-ListDots (-v a) 'b) (make-ListDots -Symbol 'b) #:vars '(a))
107108
(infer-t (make-ListDots -Symbol 'b) (make-ListDots Univ 'b) #:indices '(b))
@@ -130,7 +131,6 @@
130131
[infer-t (-lst* -String) (make-ListDots -Symbol 'b) #:indices '(b) #:fail]
131132

132133
;; Currently Broken
133-
;(infer-t (-lst -Symbol) (make-ListDots -Symbol 'b) #:indices '(b))
134134
;(infer-t (make-ListDots (-v b) 'b) (make-ListDots -Symbol 'b) #:indices '(b))
135135
;(infer-t (make-ListDots -Symbol 'b) (make-ListDots (-v b) 'b) #:indices '(b))
136136
;(infer-t (make-ListDots -Symbol 'b) (-pair -Symbol (-lst -Symbol)) #:indices '(b))

0 commit comments

Comments
 (0)