I'm not sure if this is correct, but this handles the cases where we're

instantiating dotted pre-types where the bound is _not_ free in the
pre-type base.  I checked in a test case for this, that's something like:

(inst (plambda: (a ...) [ys : (Number ... a -> Number)] (apply + ys))
      Integer Boolean String)
 =
(Number Number Number -> Number)

These changes introduce no extra test failures, and we really have to
account for the bound here, and really even if the variable _does_
appear free within the pre-type base, it shouldn't be counted as a
"regular" variable outside of that scope.

Actually, maybe Dotted should behave like Constant, where it just
propogates until there's a separate free use that we're merging with,
in which case we just treat it like the free use (which will
eventually get fix-bound applied to it anyway).  I think I'll make
that change next.
This commit is contained in:
Stevie Strickland 2008-07-12 22:30:00 -04:00
parent 9b289bea27
commit f3eb315425
3 changed files with 9 additions and 6 deletions

View File

@ -43,7 +43,8 @@
(cond
[(eq? v w) v]
[(or (eq? v Dotted) (eq? w Dotted))
(int-err "Cannot combine Dotted w/ not Dotted: ~a ~a" v w)]
Invariant
#;(int-err "Cannot combine Dotted w/ not Dotted: ~a ~a" v w)]
[(eq? v Constant) w]
[(eq? w Constant) v]
[else Invariant]))
@ -63,7 +64,7 @@
(define (fix-bound vs bound)
(define vs* (hash-map* (lambda (k v) v) vs))
(hash-remove! vs* bound)
(hash-set! vs* bound (cons bound Dotted))
(hash-set! vs* bound Dotted)
vs*)
;; frees -> frees

View File

@ -413,7 +413,8 @@
[Constant S]
[Covariant S]
[Contravariant T]
[Invariant S]))]))
[Invariant S]
[Dotted T]))]))
(match (car (cset-maps C))
[(cons cmap (struct dmap (dm)))
(check-vars

View File

@ -101,9 +101,8 @@
(dt arr (dom rng rest drest thn-eff els-eff)
[#:frees (combine-frees (append (map flip-variances (map free-vars* (append (if rest (list rest) null) dom)))
(match drest
#;[(cons t (? symbol? bnd))
(let ([vs (free-vars* t)])
(list (flip-variances vs)))]
[(cons t (? symbol? bnd))
(list (fix-bound (flip-variances (free-vars* t)) bnd))]
[(cons t bnd) (list (flip-variances (free-vars* t)))]
[_ null])
(list (free-vars* rng))
@ -111,6 +110,8 @@
(map free-vars* (append thn-eff els-eff)))))
(combine-frees (append (map flip-variances (map free-idxs* (append (if rest (list rest) null) dom)))
(match drest
[(cons t (? number? bnd))
(list (fix-bound (flip-variances (free-idxs* t)) bnd))]
[(cons t bnd) (list (flip-variances (free-idxs* t)))]
[_ null])
(list (free-idxs* rng))