Handle union of different values for functions too
Closes PR 14557 original commit: b3a477d6180332a1bdc413ad3e710666df521718
This commit is contained in:
parent
e03538a1ac
commit
47cb2e7469
|
@ -173,9 +173,9 @@
|
|||
(tc/funapp f-stx args-stx (ret (resolve-once t) f o) argtys expected)]
|
||||
;; a union of functions can be applied if we can apply all of the elements
|
||||
[((tc-result1: (Union: (and ts (list (Function: _) ...)))) _)
|
||||
(ret (for/fold ([result (Un)]) ([fty (in-list ts)])
|
||||
(match (tc/funapp f-stx args-stx (ret fty) argtys expected)
|
||||
[(tc-result1: t) (Un result t)])))]
|
||||
(merge-tc-results
|
||||
(for/list ([fty ts])
|
||||
(tc/funapp f-stx args-stx (ret fty) argtys expected)))]
|
||||
;; error type is a perfectly good fcn type
|
||||
[((tc-result1: (Error:)) _) (ret (make-Error))]
|
||||
;; otherwise fail
|
||||
|
|
|
@ -3007,6 +3007,20 @@
|
|||
#:ret (ret (-seq (-vec Univ)))
|
||||
#:expected (ret (-seq (-vec Univ)))]
|
||||
|
||||
;; PR 14557 - apply union of functions with different return values
|
||||
[tc-err
|
||||
(let ()
|
||||
(: f (U (-> Void) (-> (values Void Void))))
|
||||
(define (f) (void))
|
||||
(f))
|
||||
#:msg #rx"Expected the same number of values.*1 and 2"]
|
||||
[tc-e
|
||||
(let ()
|
||||
(: f (U (-> (values String Symbol)) (-> (values Void Void))))
|
||||
(define (f) (values "foo" 'bar))
|
||||
(f))
|
||||
#:ret (ret (list (t:Un -String -Void) (t:Un -Symbol -Void)))]
|
||||
|
||||
)
|
||||
|
||||
(test-suite
|
||||
|
|
Loading…
Reference in New Issue
Block a user