Skip to content

Commit fce9851

Browse files
committed
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.
1 parent 02d046d commit fce9851

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-contract.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@
515515
" with optional keyword arguments")))
516516
(if case->
517517
(arr/sc (process-dom (map t->sc/neg dom))
518-
(and rst (t->sc/neg rst))
518+
(and rst (listof/sc (t->sc/neg rst)))
519519
(map t->sc rngs))
520520
(function/sc
521521
(process-dom (map t->sc/neg dom))

pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/contract-tests.rkt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,9 @@
213213
(λ (x) 1)
214214
#:untyped
215215
#:msg #rx"produced: 1.*blaming: untyped")
216+
(t-int (cl->* (->* '() -String -String)
217+
(->* (list -Symbol) -Symbol -Symbol))
218+
(λ (f) (f "a" "b"))
219+
(case-lambda [xs (car xs)]
220+
[(sym . xs) sym]))
216221
))

0 commit comments

Comments
 (0)