From f2bf1062bcdc2f9ead7e1c95c6d58355add6a002 Mon Sep 17 00:00:00 2001 From: Andrew Kent Date: Sat, 1 Jul 2017 18:11:18 +0100 Subject: [PATCH] erase object when inst is present (#572) --- typed-racket-lib/typed-racket/typecheck/tc-expression.rkt | 6 +++++- typed-racket-test/unit-tests/typecheck-tests.rkt | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/typed-racket-lib/typed-racket/typecheck/tc-expression.rkt b/typed-racket-lib/typed-racket/typecheck/tc-expression.rkt index 5a3f1f5a..830b3050 100644 --- a/typed-racket-lib/typed-racket/typecheck/tc-expression.rkt +++ b/typed-racket-lib/typed-racket/typecheck/tc-expression.rkt @@ -58,7 +58,11 @@ number)) (match tc-res [(tc-results: (list (tc-result: t ps o)) #f) - (ret (inst-type t inst) ps o)] + ;; we erase 'o' -- if they bothered to put an instantiation, + ;; odds are this is not something where 'o' matters, and leaving + ;; 'o' can cause complications (see TR gh issue 561) -- maybe there's + ;; a better way? this seems totally fine for now + (ret (inst-type t inst) ps -empty-obj)] [_ (error-case (if (and (tc-results? tc-res) (null? (tc-results-ts tc-res))) 0 diff --git a/typed-racket-test/unit-tests/typecheck-tests.rkt b/typed-racket-test/unit-tests/typecheck-tests.rkt index 50c92fa7..3589580f 100644 --- a/typed-racket-test/unit-tests/typecheck-tests.rkt +++ b/typed-racket-test/unit-tests/typecheck-tests.rkt @@ -1188,7 +1188,7 @@ ((-lst y) y) . ->... . (-lst z))) : -true-propset - : (-id-path #'map)))] + : -empty-obj))] ;; error tests [tc-err (+ 3 #f)] @@ -3966,6 +3966,10 @@ ;; * Check that when passed as a #:∀ type, the inferred type is Char [tc-e #\b -Char] [tc-e (ann #\b Char) -Char] + ;; TR github issue 561 + [tc-e (let ([a (inst cons Integer Integer)]) + (cons #f #f)) + (-pair -False -False)] ) (test-suite