Improve error message for calls to 'sort' when inference fails.

original commit: b124d68f402ce99ddec58482be40ce279f3f4a04
This commit is contained in:
Vincent St-Amour 2011-08-03 17:05:52 -04:00
parent ada104f62e
commit ffcc7e9f92
2 changed files with 8 additions and 0 deletions

View File

@ -0,0 +1,5 @@
#;
(exn-pred exn:fail:syntax? #rx".*Cannot infer.*Please add more type annotations.*")
#lang typed/racket
(define ss '("one" "two" "three")) ; (Listof String)
(sort ss string<?)

View File

@ -124,6 +124,9 @@
;; error type is a perfectly good fcn type
[((tc-result1: (Error:)) _) (ret (make-Error))]
;; otherwise fail
[((tc-result1: (and f-ty (Poly: ns (Function: arrs)))) _)
(tc-error/expr #:return (ret (Un))
"Cannot infer type instantiation for type ~a. Please add more type annotations" f-ty)]
[((tc-result1: f-ty) _)
(tc-error/expr #:return (ret (Un))
"Cannot apply expression of type ~a, since it is not a function type" f-ty)]))