Remove unused variable in constraint struct.
original commit: 895ab035d25aef445980461490357f34e3932d43
This commit is contained in:
parent
e716654c23
commit
951d8ed2d7
|
@ -3,9 +3,8 @@
|
|||
(require "../utils/utils.rkt" (rep type-rep) (contract-req) racket/match (for-syntax racket/base syntax/parse))
|
||||
|
||||
;; S, T types
|
||||
;; X a var
|
||||
;; represents S <: X <: T (see "Local Type Inference" pg. 12)
|
||||
(define-struct/cond-contract c ([S Type/c] [X symbol?] [T Type/c]) #:transparent)
|
||||
(define-struct/cond-contract c ([S Type/c] [T Type/c]) #:transparent)
|
||||
|
||||
;; fixed : Listof[c]
|
||||
;; rest : option[c]
|
||||
|
@ -36,12 +35,6 @@
|
|||
;; don't want to rule them out too early
|
||||
(define-struct/cond-contract cset ([maps (listof (cons/c (hash/c symbol? c? #:immutable #t) dmap?))]) #:transparent)
|
||||
|
||||
(define-match-expander c:
|
||||
(lambda (stx)
|
||||
(syntax-parse stx
|
||||
[(_ s x t)
|
||||
#'(struct c (s x t))])))
|
||||
|
||||
(provide-for-cond-contract dcon/c)
|
||||
(provide
|
||||
(struct-out cset)
|
||||
|
@ -49,5 +42,4 @@
|
|||
(struct-out dcon)
|
||||
(struct-out dcon-dotted)
|
||||
(struct-out dcon-exact)
|
||||
(struct-out c)
|
||||
c:)
|
||||
(struct-out c))
|
||||
|
|
|
@ -12,15 +12,14 @@
|
|||
(export constraints^)
|
||||
|
||||
;; Widest constraint possible
|
||||
(define (no-constraint v)
|
||||
(make-c (Un) v Univ))
|
||||
(define no-constraint (make-c (Un) Univ))
|
||||
|
||||
;; Create an empty constraint map from a set of type variables X and
|
||||
;; index variables Y. For now, we add the widest constraints for
|
||||
;; variables in X to the cmap and create an empty dmap.
|
||||
(define (empty-cset X Y)
|
||||
(make-cset (list (cons (for/hash ([x (in-list X)])
|
||||
(values x (no-constraint x)))
|
||||
(values x no-constraint))
|
||||
(make-dmap (make-immutable-hash null))))))
|
||||
|
||||
|
||||
|
@ -29,7 +28,7 @@
|
|||
(match cs
|
||||
[(struct cset (maps))
|
||||
(make-cset (for/list ([(map dmap) (in-pairs maps)])
|
||||
(cons (hash-set map var (make-c S var T))
|
||||
(cons (hash-set map var (make-c S T))
|
||||
dmap)))]))
|
||||
|
||||
;; meet: Type Type -> Type
|
||||
|
@ -54,12 +53,10 @@
|
|||
;; `c2`)
|
||||
(define (c-meet c1 c2 [var #f])
|
||||
(match*/early (c1 c2)
|
||||
[((struct c (S X T)) (struct c (S* X* T*)))
|
||||
(unless (or var (eq? X X*))
|
||||
(int-err "Non-matching vars in c-meet: ~a ~a" X X*))
|
||||
[((struct c (S T)) (struct c (S* T*)))
|
||||
(let ([S (join S S*)] [T (meet T T*)])
|
||||
(and (subtype S T)
|
||||
(make-c S (or var X) T)))]))
|
||||
(make-c S T)))]))
|
||||
|
||||
;; compute the meet of two constraint sets
|
||||
;; returns #f for failure
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
(% make-dcon-exact
|
||||
(for/list/fail ([c1 (in-list fixed1)]
|
||||
[c2 (in-list fixed2)])
|
||||
(c-meet c1 c2 (c-X c1)))
|
||||
(c-meet rest1 rest2 (c-X rest1)))]
|
||||
(c-meet c1 c2))
|
||||
(c-meet rest1 rest2))]
|
||||
;; redo in the other order to call the previous case
|
||||
[((struct dcon (fixed1 rest1)) (struct dcon-exact (fixed2 rest2)))
|
||||
(dcon-meet dc2 dc1)]
|
||||
|
@ -32,7 +32,7 @@
|
|||
(%1 make-dcon
|
||||
(for/list/fail ([c1 (in-list fixed1)]
|
||||
[c2 (in-list fixed2)])
|
||||
(c-meet c1 c2 (c-X c1)))
|
||||
(c-meet c1 c2))
|
||||
#f)]
|
||||
[((struct dcon (fixed1 #f)) (struct dcon (fixed2 rest)))
|
||||
#:return-unless (>= (length fixed1) (length fixed2))
|
||||
|
@ -40,7 +40,7 @@
|
|||
(%1 make-dcon
|
||||
(for/list/fail ([c1 (in-list fixed1)]
|
||||
[c2 (in-sequence-forever fixed2 rest)])
|
||||
(c-meet c1 c2 (c-X c1)))
|
||||
(c-meet c1 c2))
|
||||
#f)]
|
||||
;; redo in the other order to call the previous case
|
||||
[((struct dcon (fixed1 rest)) (struct dcon (fixed2 #f)))
|
||||
|
@ -53,15 +53,15 @@
|
|||
(% make-dcon
|
||||
(for/list/fail ([c1 (in-list longer)]
|
||||
[c2 (in-sequence-forever shorter srest)])
|
||||
(c-meet c1 c2 (c-X c1)))
|
||||
(c-meet lrest srest (c-X lrest))))]
|
||||
(c-meet c1 c2))
|
||||
(c-meet lrest srest)))]
|
||||
[((struct dcon-dotted (fixed1 c1 bound1)) (struct dcon-dotted (fixed2 c2 bound2)))
|
||||
#:return-unless (and (= (length fixed1) (length fixed2))
|
||||
(eq? bound1 bound2))
|
||||
#f
|
||||
(% make-dcon-dotted (for/list/fail ([c1 (in-list fixed1)] [c2 (in-list fixed2)])
|
||||
(c-meet c1 c2 (c-X c1)))
|
||||
(c-meet c1 c2 bound1) bound1)]
|
||||
(c-meet c1 c2))
|
||||
(c-meet c1 c2) bound1)]
|
||||
[((struct dcon _) (struct dcon-dotted _))
|
||||
#f]
|
||||
[((struct dcon-dotted _) (struct dcon _))
|
||||
|
|
|
@ -697,7 +697,7 @@
|
|||
;; variance : Variance
|
||||
(define (constraint->type v variance)
|
||||
(match v
|
||||
[(c S _ T)
|
||||
[(c S T)
|
||||
(evcase variance
|
||||
[Constant S]
|
||||
[Covariant S]
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
(define-signature constraints^
|
||||
([cond-contracted cset-meet ((cset? cset?) #:rest (listof cset?) . ->* . (or/c #f cset?))]
|
||||
[cond-contracted cset-meet* ((listof cset?) . -> . (or/c #f cset?))]
|
||||
no-constraint
|
||||
[cond-contracted empty-cset ((listof symbol?) (listof symbol?) . -> . cset?)]
|
||||
[cond-contracted insert (cset? symbol? Type/c Type/c . -> . cset?)]
|
||||
[cond-contracted cset-join ((listof cset?) . -> . cset?)]
|
||||
|
|
Loading…
Reference in New Issue
Block a user