From bb3f446186fc9b4ca110fdf27fa4e20c633463d8 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Tue, 9 Sep 2014 10:45:43 -0400 Subject: [PATCH] Merge clauses even when no clause is consistent with the expected type. Closes PR14731. original commit: 3ae6d2aa46415aac6041c6b7c1d7841f1dc8dd72 --- .../typed-racket/typecheck/tc-app-helper.rkt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-app-helper.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-app-helper.rkt index 7a2ae295..aeac33bd 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-app-helper.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-app-helper.rkt @@ -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