Merge clauses even when no clause is consistent with the expected type.

Closes PR14731.

original commit: 3ae6d2aa46415aac6041c6b7c1d7841f1dc8dd72
This commit is contained in:
Vincent St-Amour 2014-09-09 10:45:43 -04:00
parent 34eeeb62bc
commit bb3f446186

View File

@ -251,7 +251,7 @@
;; iterate in lock step over the function types we analyze and the parts
;; that we will need to print the error message, to make sure we throw
;; away cases consistently
(define-values (candidates parts-acc)
(define-values (candidates* parts-acc*)
(for/fold ([candidates '()] ; from cases
[parts-acc '()]) ; from orig
([c (in-list cases)]
@ -261,7 +261,14 @@
(values (cons c candidates) ; we keep this one
(cons p parts-acc))
;; we discard this one
(values candidates parts-acc))))
(values candidates parts-acc))))
;; if none of the cases return a subtype of the expected type, still do some
;; merging, but do it on the entire type
(define-values (candidates parts-acc)
(if (null? candidates*)
(values cases orig)
(values candidates* parts-acc*)))
;; among the domains that fit with the expected type, we only need to
;; keep the most liberal