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 7de04b06..0c735ff0 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 @@ -101,7 +101,6 @@ (define (domain-mismatches f-stx args-stx ty doms rests drests rngs arg-tys tail-ty tail-bound #:expected [expected #f] #:return [return -Bottom] #:msg-thunk [msg-thunk (lambda (dom) dom)]) - (define arguments-str (stringify-domain arg-tys (if (not tail-bound) tail-ty #f) @@ -155,7 +154,9 @@ (if (null? pdoms) (values doms rngs rests drests) (values pdoms prngs prests pdrests))]) - (if (= (length pdoms) 1) + (if ;; only use `tc/funapp1` if `tail-ty` was *not* provided + ;; since it either won't error correctly or produces a poor error + (and (not tail-ty) (= (length pdoms) 1)) ;; if we narrowed down the possible cases to a single one, have ;; tc/funapp1 generate a better error message (begin (tc/funapp1 f-stx args-stx diff --git a/pkgs/typed-racket-pkgs/typed-racket-tests/tests/typed-racket/fail/pr13893.rkt b/pkgs/typed-racket-pkgs/typed-racket-tests/tests/typed-racket/fail/pr13893.rkt new file mode 100644 index 00000000..376187b6 --- /dev/null +++ b/pkgs/typed-racket-pkgs/typed-racket-tests/tests/typed-racket/fail/pr13893.rkt @@ -0,0 +1,21 @@ +#; +(exn:pred #rx"Bad arguments to function in apply") +#lang typed/racket + +;; Make sure that case-> types with multiple branches that +;; includes a * domain produce a type error instead of +;; accidentally type-checking. + +;; from the PR +(: x (Listof Number)) +(define x (apply + (list 1 2 "3"))) + +(: g (-> (Listof Number))) +(define (g) (apply + (list 1 2 "3"))) + +;; additional case +(: f (case-> (Integer * -> Integer) + (Real * -> Real))) +(define (f . args) (+ 1 (list-ref args 2))) +(apply f (list 1 2 "3")) +