Allow `apply' of non-uniform polymorphic functions to fixed-length list arguments.
Please backport. svn: r14162 original commit: 0ed8d251bff94224448a2d860d329a7427513a61
This commit is contained in:
parent
3bcaed5d41
commit
fdfa1cd04a
25
collects/tests/typed-scheme/succeed/apply-dots-list.ss
Normal file
25
collects/tests/typed-scheme/succeed/apply-dots-list.ss
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
;; Change the lang to scheme for untyped version
|
||||
#lang typed-scheme
|
||||
|
||||
(define tests (list (list (λ() 1) 1 "test 1")
|
||||
(list (λ() 2) 2 "test 2")))
|
||||
|
||||
; Comment out the type signature when running untyped
|
||||
(: check-all (All (A ...) ((List (-> A) A String) ... A -> Void)))
|
||||
(define (check-all . tests)
|
||||
(let aux ([tests tests]
|
||||
[num-passed 0])
|
||||
(if (null? tests)
|
||||
(printf "~a tests passed.~n" num-passed)
|
||||
(let ((test (car tests)))
|
||||
(let ((actual ((car test)))
|
||||
(expected (cadr test))
|
||||
(msg (caddr test)))
|
||||
(if (equal? actual expected)
|
||||
(aux (cdr tests) (+ num-passed 1))
|
||||
(printf "Test failed: ~a. Expected ~a, got ~a.~n"
|
||||
msg expected actual)))))))
|
||||
|
||||
(apply check-all tests) ; Works in untyped, but not in typed
|
||||
(check-all (car tests) (cadr tests)) ; Works in typed or untyped
|
|
@ -342,6 +342,19 @@
|
|||
drest-bound
|
||||
(subst-all (alist-delete drest-bound substitution eq?)
|
||||
(car rngs*)))))]
|
||||
;; ... function, (List A B C etc) arg
|
||||
[(and (car drests*)
|
||||
(not tail-bound)
|
||||
(eq? (cdr (car drests*)) dotted-var)
|
||||
(= (length (car doms*))
|
||||
(length arg-tys))
|
||||
(untuple tail-ty)
|
||||
(infer/dots fixed-vars dotted-var (append arg-tys (untuple tail-ty)) (car doms*)
|
||||
(car (car drests*)) (car rngs*) (fv (car rngs*))))
|
||||
=> (lambda (substitution)
|
||||
(define drest-bound (cdr (car drests*)))
|
||||
(do-apply-log substitution 'dots 'dots)
|
||||
(ret (subst-all substitution (car rngs*))))]
|
||||
;; if nothing matches, around the loop again
|
||||
[else (loop (cdr doms*) (cdr rngs*) (cdr rests*) (cdr drests*))])))]
|
||||
[(tc-result: (PolyDots: vars (Function: '())))
|
||||
|
|
Loading…
Reference in New Issue
Block a user