Skip to content

Commit 8bb4f07

Browse files
committed
bug fix
1 parent 5e59b9b commit 8bb4f07

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"signatures.rkt" "fail.rkt"
2323
"promote-demote.rkt"
2424
racket/match
25+
(only-in racket/function curry curryr)
2526
;racket/trace
2627
(contract-req)
2728
(for-syntax
@@ -576,35 +577,38 @@
576577
[(F: v*) (and (bound-index? v*) (not (bound-tvar? v*)))]
577578
[_ #f])
578579
#f
579-
;; constrain v to be below T (but don't mention bounds)
580580
(define maybe-type-bound (hash-ref (context-type-bounds context) v #f))
581581
(if maybe-type-bound
582582
(if (subtype maybe-type-bound T obj)
583583
(singleton maybe-type-bound
584584
v
585585
(var-demote T (context-bounds context)))
586586
#f)
587-
(singleton -Bottom
588-
v
589-
(var-demote T (context-bounds context))))]
587+
;; constrain v to be below T (but don't mention bounds)
588+
(singleton -Bottom v (var-demote T (context-bounds context))))]
590589

591590
[(S (F: (? (inferable-var? context) v)))
592591
#:return-when
593592
(match S
594593
[(F: v*) (and (bound-index? v*) (not (bound-tvar? v*)))]
595594
[_ #f])
596595
#f
597-
(define maybe-type-bound (hash-ref (context-type-bounds context) v #f))
598596
;; constrain v to be above S (but don't mention bounds)
597+
(define maybe-type-bound (hash-ref (context-type-bounds context) v #f))
598+
(let ([sing (curry singleton (var-promote S (context-bounds context)) v)])
599+
(cond
600+
[(and maybe-type-bound (subtype S maybe-type-bound obj))
601+
(sing maybe-type-bound)]
602+
[(not maybe-type-bound) (sing Univ)]
603+
[else #f]))
604+
#;
599605
(if maybe-type-bound
600606
(if (subtype S maybe-type-bound obj)
601607
(singleton (var-demote S (context-bounds context))
602608
v
603609
maybe-type-bound)
604610
#f)
605-
(singleton (var-demote S (context-bounds context))
606-
v
607-
Univ))]
611+
(singleton (var-promote S (context-bounds context)) v Univ))]
608612

609613
;; recursive names should get resolved as they're seen
610614
[(s (? Name? t))

0 commit comments

Comments
 (0)