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 c8ecbb75..f4334a48 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 @@ -105,8 +105,11 @@ (if tail-bound (cons tail-ty tail-bound) #f))) (cond [(null? doms) - (tc-error/expr "cannot apply function of type Procedure" - #:return return)] + (tc-error/expr/fields + "cannot apply a function with unknown arity" + #:more (format "~a has type Procedure which cannot be applied" + (name->function-str (and (identifier? f-stx) f-stx))) + #:return return)] [(and (= 1 (length doms)) (not (car rests)) (not (car drests)) (not tail-ty) (not tail-bound)) (tc-error/expr #:return return @@ -332,9 +335,7 @@ (PolyRow-names: msg-vars _ (Function/arrs: msg-doms msg-rngs msg-rests msg-drests (list (Keyword: _ _ #f) ...)))) - (let ([fcn-string (if name - (format "function `~a'" (syntax->datum name)) - "function")]) + (let ([fcn-string (name->function-str name)]) (if (and (andmap null? msg-doms) (null? argtypes)) (tc-error/expr (string-append @@ -374,3 +375,9 @@ (string-append "Type Variables: " (stringify msg-vars) "\n") ""))))))])) +;; name->function-str : (Option Identifier) -> String +;; Produce a function name string for error messages +(define (name->function-str name) + (if name + (format "function `~a'" (syntax->datum name)) + "function")) diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt index 2e2230f8..f516bee1 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt @@ -3113,7 +3113,7 @@ (: f Procedure) (define f (lambda () 'hi)) (f)) - #:msg "cannot apply function of type Procedure"] + #:msg "function with unknown arity"] ;; PR 13259 [tc-err