From e118bb590071898c7a0d8d0319da24389ce4f60d Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Fri, 16 May 2014 14:59:43 -0400 Subject: [PATCH] Fix rest arg contract generation for case-> types The generated contracts are still not ideal when more than one case has a rest argument, since a later case in the case-> contract may pass but case-> won't try all of them. original commit: fce98517e6ba4954dfa8920e31e7e3eef50155ca --- .../typed-racket-lib/typed-racket/private/type-contract.rkt | 2 +- .../tests/typed-racket/unit-tests/contract-tests.rkt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-contract.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-contract.rkt index a14e53da..6540f68c 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-contract.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-contract.rkt @@ -515,7 +515,7 @@ " with optional keyword arguments"))) (if case-> (arr/sc (process-dom (map t->sc/neg dom)) - (and rst (t->sc/neg rst)) + (and rst (listof/sc (t->sc/neg rst))) (map t->sc rngs)) (function/sc (process-dom (map t->sc/neg dom)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/contract-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/contract-tests.rkt index 7dfb7687..6db95616 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/contract-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/contract-tests.rkt @@ -213,4 +213,9 @@ (λ (x) 1) #:untyped #:msg #rx"produced: 1.*blaming: untyped") + (t-int (cl->* (->* '() -String -String) + (->* (list -Symbol) -Symbol -Symbol)) + (λ (f) (f "a" "b")) + (case-lambda [xs (car xs)] + [(sym . xs) sym])) ))