From f2de6dfee9934649d361f33b524ef0a77c38ae18 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Mon, 2 Dec 2013 12:20:36 -0500 Subject: [PATCH] Fix type expansion suggestion. Closes PR14212. --- .../typed-racket/typecheck/tc-app-helper.rkt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 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 a6c1e053a9..e5fd9693bf 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 @@ -306,9 +306,14 @@ ;; function type, prune if possible. [(Function: (list (arr: doms rngs rests drests kws) ...)) (match-let ([(list pdoms rngs rests drests) (possible-domains doms rests drests rngs (and expected (ret expected)))]) - (let ([res (make-Function (map make-arr - pdoms rngs rests drests (make-list (length pdoms) null)))]) - res))] + (if (= (length pdoms) (length doms)) + ;; pruning didn't improve things, return the original + ;; (Note: pruning may have reordered clauses, so may not be `equal?' to + ;; the original, which may confuse `:print-type''s pruning detection) + t + ;; pruning helped, return pruned type + (make-Function (map make-arr + pdoms rngs rests drests (make-list (length pdoms) null)))))] ;; not a function type. keep as is. [_ t]))