propagate expected type through lambda
fixes https://bitbucket.org/stchang/macrotypes/issues/4
This commit is contained in:
parent
6f48690446
commit
9332309160
|
@ -412,6 +412,9 @@
|
|||
(define-typed-syntax liftedλ #:export-as λ
|
||||
[(_ (y:id x:id ...) . body)
|
||||
(type-error #:src stx #:msg "λ parameters must have type annotations")]
|
||||
[(_ args body)
|
||||
#:with (~∀ () (~ext-stlc:→ arg-ty ... body-ty)) (get-expected-type stx)
|
||||
#`(Λ () (ext-stlc:λ args #,(add-expected-ty #'body #'body-ty)))]
|
||||
[(_ . rst)
|
||||
#'(Λ () (ext-stlc:λ . rst))])
|
||||
|
||||
|
|
|
@ -61,3 +61,14 @@
|
|||
(check-type alias-test2 : (→/test B (Read-Result B)))
|
||||
(check-type alias-test3 : (→/test B (Result (× B (List Char)) String)))
|
||||
(check-type alias-test3 : (→/test B (Read-Result B)))
|
||||
|
||||
(define (expect-listof-int [loi : (List Int)] → Int)
|
||||
0)
|
||||
|
||||
(check-type (expect-listof-int nil) : Int -> 0)
|
||||
|
||||
(define (expect-→listof-int [f : (→ (List Int))] → Int)
|
||||
0)
|
||||
|
||||
(check-type (expect-→listof-int (λ () nil)) : Int -> 0)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user