finally. part2
This commit is contained in:
parent
b1cc807d45
commit
14b79a7d2a
@ -83,14 +83,12 @@
|
||||
(if (empty? keys)
|
||||
#t
|
||||
(let ([key (first keys)])
|
||||
(type-case (Optionof Type) (hash-ref Y-fields key)
|
||||
[(none) #f] ;; Key not found in Y-fields
|
||||
[(some Y-type)
|
||||
(let ([Y-type (some-v (hash-ref Y-fields key))])
|
||||
(type-case (Optionof Type) (hash-ref X-fields key)
|
||||
[(none) #f] ;; Key not found in X-fields
|
||||
[(some X-type)
|
||||
(and (subtype? X-type Y-type) ;; Check subtyping of field types
|
||||
(loop (rest keys)))])]))))] ;; Recurse on remaining keys
|
||||
(loop (rest keys)))])))))] ;; Recurse on remaining keys
|
||||
(loop (hash-keys Y-fields)))]
|
||||
[else #f])]))
|
||||
|
||||
@ -322,5 +320,11 @@
|
||||
(test (subtype? (arrowT hello-goodbye-t hello-goodbye-t)
|
||||
(arrowT hello-t hello-t)) #f)
|
||||
;; for coverage
|
||||
(define non-object-fun `{lam {x : num} {msg x hello}})
|
||||
;; `x` is bound to `numT`, which is not an object type
|
||||
(test/exn (tc non-object-fun) "bound variable is not an object")
|
||||
(test (subtype? hello-t (boolT)) #f)
|
||||
(test (subtype? (boolT) (boolT)) #t)
|
||||
(test (subtype? (boolT) (numT)) #f)
|
||||
(test (subtype? (arrowT (numT) (numT)) (numT)) #f)
|
||||
(test (subtype? (numT) (arrowT (numT) (numT))) #f))
|
Loading…
x
Reference in New Issue
Block a user