diff --git a/collects/typed-scheme/test.ss b/collects/typed-scheme/test.ss index ea249073..097675c0 100644 --- a/collects/typed-scheme/test.ss +++ b/collects/typed-scheme/test.ss @@ -43,4 +43,9 @@ ;; Error #;#{(case-lambda: [() 1] [([x : Number]) x]) :: String} +#{(lambda: ([x : Number]) 1) :: (Number -> Number)} +#{(lambda: ([x : Number]) 1) :: Any} +#{(lambda: ([x : Number]) 1) :: (Integer -> Any)} +#{(lambda: ([x : Number]) x) :: (Number -> Number)} +#{(lambda: ([x : Number]) x) :: (Integer -> Any)} diff --git a/collects/typed-scheme/typecheck/tc-expr-unit.ss b/collects/typed-scheme/typecheck/tc-expr-unit.ss index 075cc095..c1fb45ec 100644 --- a/collects/typed-scheme/typecheck/tc-expr-unit.ss +++ b/collects/typed-scheme/typecheck/tc-expr-unit.ss @@ -136,24 +136,24 @@ (match* (tr1 expected) [((tc-results: t1) (tc-results: t2)) (unless (andmap subtype t1 t2) - (tc-error/expr "Expected ~a, but got ~a" t2 t1)) + (tc-error/expr "1 Expected ~a, but got ~a" t2 t1)) expected] [((tc-result1: t1 f o) (? Type? t2)) (unless (subtype t1 t2) - (tc-error/expr "Expected ~a, but got ~a" t2 t1)) + (tc-error/expr "1 Expected ~a, but got ~a" t2 t1)) (ret t2 f o)] [((? Type? t1) (tc-result1: t2 (FilterSet: (list) (list)) (Empty:))) (unless (subtype t1 t2) - (tc-error/expr "Expected ~a, but got ~a" t2 t1)) + (tc-error/expr "3 Expected ~a, but got ~a" t2 t1)) t1] [((? Type? t1) (tc-result1: t2 f o)) (if (subtype t1 t2) (tc-error/expr "Expected result with filter ~a and object ~a, got ~a" f o t1) - (tc-error/expr "Expected ~a, but got ~a" t2 t1)) + (tc-error/expr "4 Expected ~a, but got ~a" t2 t1)) t1] [((? Type? t1) (? Type? t2)) (unless (subtype t1 t2) - (tc-error/expr "Expected ~a, but got ~a" t2 t1)) + (tc-error/expr "5 Expected ~a, but got ~a" t2 t1)) expected])) (define (tc-expr/check/type form expected) diff --git a/collects/typed-scheme/types/subtype.ss b/collects/typed-scheme/types/subtype.ss index 14f2ab3c..4c154e5c 100644 --- a/collects/typed-scheme/types/subtype.ss +++ b/collects/typed-scheme/types/subtype.ss @@ -125,6 +125,12 @@ (match* (s t) ;; top for functions is above everything [(_ (top-arr:)) A0] + ;; the really simple case + [((arr: s1 s2 #f #f '()) + (arr: t1 t2 #f #f '())) + (subtype-seq A0 + (subtypes* t1 s1) + (subtype* s2 t2))] [((arr: s1 s2 #f #f s-kws) (arr: t1 t2 #f #f t-kws)) (subtype-seq A0 @@ -301,6 +307,9 @@ ;; trivial case for Result [(list (Result: t f o) (Result: t* f o)) (subtype* A0 t t*)] + ;; we can ignore interesting results + [(list (Result: t f o) (Result: t* (LFilterSet: (list) (list)) (LEmpty:))) + (subtype* A0 t t*)] ;; single values shouldn't actually happen, but they're just like the type [(list t (Values: (list t*))) (int-err "BUG - singleton values type~a" (make-Values (list t*)))] [(list (Values: (list t)) t*) (int-err "BUG - singleton values type~a" (make-Values (list t)))]