Adjust named-let to use the return type annotation whenever possible
Fixes #43
This commit is contained in:
parent
33543ce054
commit
c79b61a751
|
@ -439,26 +439,29 @@ This file defines two sorts of primitives. All of them are provided into any mod
|
|||
(~and (~seq (~optional (~seq : ret-ty))
|
||||
(bs:optionally-annotated-binding ...) body ...)
|
||||
(~seq rest ...)))
|
||||
(quasisyntax/loc stx
|
||||
(#,(syntax-parse #'(rest ...)
|
||||
#:literals (:)
|
||||
[(: ret-ty (bs:annotated-binding ...) . body)
|
||||
(quasisyntax/loc stx
|
||||
(-letrec ([nm : (bs.ty ... -> ret-ty)
|
||||
#,(quasisyntax/loc stx
|
||||
(lambda (bs.ann-name ...) . #,(syntax/loc stx body)))])
|
||||
#,(quasisyntax/loc stx nm)))]
|
||||
[(: ret-ty (bs:optionally-annotated-binding ...) body ... bod)
|
||||
(quasisyntax/loc stx
|
||||
(letrec ([nm #,(quasisyntax/loc stx
|
||||
(lambda (bs.ann-name ...) body ... (ann #,(syntax/loc stx bod) ret-ty)))])
|
||||
#,(quasisyntax/loc stx nm)))]
|
||||
[((bs:optionally-annotated-binding ...) . body)
|
||||
(quasisyntax/loc stx
|
||||
(letrec ([nm #,(quasisyntax/loc stx
|
||||
(lambda (bs.ann-name ...) . #,(syntax/loc stx body)))])
|
||||
#,(quasisyntax/loc stx nm)))])
|
||||
bs.rhs ...))]
|
||||
(syntax-parse #'(rest ...)
|
||||
#:literals (:)
|
||||
[(: ret-ty (bs:annotated-binding ...) . body)
|
||||
(quasisyntax/loc stx
|
||||
((-letrec ([nm : (bs.ty ... -> ret-ty)
|
||||
#,(quasisyntax/loc stx
|
||||
(lambda (bs.ann-name ...) . #,(syntax/loc stx body)))])
|
||||
#,(quasisyntax/loc stx nm))
|
||||
bs.rhs ...))]
|
||||
[(: ret-ty (bs:optionally-annotated-binding ...) body ... bod)
|
||||
(quasisyntax/loc stx
|
||||
(ann
|
||||
((letrec ([nm #,(quasisyntax/loc stx
|
||||
(lambda (bs.ann-name ...) body ... (ann #,(syntax/loc stx bod) ret-ty)))])
|
||||
#,(quasisyntax/loc stx nm))
|
||||
bs.rhs ...)
|
||||
ret-ty))]
|
||||
[((bs:optionally-annotated-binding ...) . body)
|
||||
(quasisyntax/loc stx
|
||||
((letrec ([nm #,(quasisyntax/loc stx
|
||||
(lambda (bs.ann-name ...) . #,(syntax/loc stx body)))])
|
||||
#,(quasisyntax/loc stx nm))
|
||||
bs.rhs ...))])]
|
||||
[(-let vars:lambda-type-vars
|
||||
([bn:optionally-annotated-name e] ...)
|
||||
. rest)
|
||||
|
|
11
typed-racket-test/succeed/gh-issue-43.rkt
Normal file
11
typed-racket-test/succeed/gh-issue-43.rkt
Normal file
|
@ -0,0 +1,11 @@
|
|||
#lang typed/racket
|
||||
|
||||
(let loop : Integer ([n 10])
|
||||
(cond
|
||||
[(= n 5) n]
|
||||
[else (loop (sub1 n))]))
|
||||
|
||||
(let loop : Integer ([n : Integer 10])
|
||||
(cond
|
||||
[(= n 5) n]
|
||||
[else (loop (sub1 n))]))
|
Loading…
Reference in New Issue
Block a user