From 5cb96eff46a6cba3636f566a94932a33d834363b Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 3 Jul 2014 17:21:06 -0400 Subject: [PATCH] Fix `possible-domains' function in TR internals This fixes type error message generation in some cases and also the `query-type/result` command on multiple valued functions. The latter still does not allow multiple return type queries (TODO) but it won't crash now. Closes PR 14493 original commit: 881d5de9a0202f09fb5ff8baedcf75b13fa5c294 --- .../typed-racket/typecheck/tc-app-helper.rkt | 5 +++-- .../tests/typed-racket/unit-tests/interactive-tests.rkt | 4 +++- .../tests/typed-racket/unit-tests/typecheck-tests.rkt | 9 +++++++++ 3 files changed, 15 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 f4334a48..7a2ae295 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 @@ -230,8 +230,9 @@ [(Values: (list (Result: t _ _))) t] [(ValuesDots: (list (Result: t _ _)) _ _) - t])]) - (subtype rng expected-ty))])))) + t] + [_ #f])]) + (and rng (subtype rng expected-ty)))])))) (define orig (map list doms rngs rests drests)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/interactive-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/interactive-tests.rkt index ac749dba..e30068a3 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/interactive-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/interactive-tests.rkt @@ -168,4 +168,6 @@ (test-form-exn #rx"exactly two arguments" (:query-type/result)) (test-form-exn #rx"exactly two arguments" - (:query-type/result 1 2 3)))) + (:query-type/result 1 2 3)) + (test-form #rx"not in the given function's range" + (:query-type/result syntax-local-expand-expression Boolean)))) 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 f516bee1..dcb10d30 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 @@ -3123,6 +3123,15 @@ y) #:ret (ret -String -true-filter) #:msg #rx"expected: String.*given: (Null|'\\(\\))"] + + ;; PR 14493 + [tc-err + (let () + (define f values) + (: g (Any -> Boolean)) + (define (g x) (f x)) + (error "foo")) + #:msg #rx"Polymorphic function `f' could not be applied"] ) (test-suite