From a7230e377975008454e3798bee51dc253c874b78 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Thu, 2 Feb 2012 16:00:02 -0500 Subject: [PATCH] Fix printing of types in instantiation error messages. Closes PR 12507. original commit: b194916ad6a464c9a8a405c74dd203d7e023fb44 --- collects/typed-racket/typecheck/tc-expr-unit.rkt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/collects/typed-racket/typecheck/tc-expr-unit.rkt b/collects/typed-racket/typecheck/tc-expr-unit.rkt index 2cc381a6..40d5bff2 100644 --- a/collects/typed-racket/typecheck/tc-expr-unit.rkt +++ b/collects/typed-racket/typecheck/tc-expr-unit.rkt @@ -4,7 +4,7 @@ (require (rename-in "../utils/utils.rkt" [private private-in]) racket/match (prefix-in - scheme/contract) "signatures.rkt" "tc-envops.rkt" "tc-metafunctions.rkt" "tc-subst.rkt" - "check-below.rkt" "tc-funapp.rkt" + "check-below.rkt" "tc-funapp.rkt" "tc-app-helper.rkt" (types utils convenience union subtype remove-intersect type-table filter-ops) (private-in parse-type type-annotation) (rep type-rep) @@ -130,17 +130,18 @@ ([inst (in-improper-stx inst)]) (cond [(not inst) ty] [(not (or (Poly? ty) (PolyDots? ty))) - (tc-error/expr #:return (Un) "Cannot instantiate non-polymorphic type ~a" ty)] + (tc-error/expr #:return (Un) "Cannot instantiate non-polymorphic type ~a" + (cleanup-type ty))] [(and (Poly? ty) (not (= (length (syntax->list inst)) (Poly-n ty)))) (tc-error/expr #:return (Un) "Wrong number of type arguments to polymorphic type ~a:\nexpected: ~a\ngot: ~a" - ty (Poly-n ty) (length (syntax->list inst)))] + (cleanup-type ty) (Poly-n ty) (length (syntax->list inst)))] [(and (PolyDots? ty) (not (>= (length (syntax->list inst)) (sub1 (PolyDots-n ty))))) ;; we can provide 0 arguments for the ... var (tc-error/expr #:return (Un) "Wrong number of type arguments to polymorphic type ~a:\nexpected at least: ~a\ngot: ~a" - ty (sub1 (PolyDots-n ty)) (length (syntax->list inst)))] + (cleanup-type ty) (sub1 (PolyDots-n ty)) (length (syntax->list inst)))] [(PolyDots? ty) ;; In this case, we need to check the last thing. If it's a dotted var, then we need to ;; use instantiate-poly-dotted, otherwise we do the normal thing.