Fix for/fold typechecking on null accumulator

Closes PR 13259

original commit: 0b3b1f5d9469da8990517dc11d7e63a7302d7966
This commit is contained in:
Asumu Takikawa 2014-06-27 00:01:49 -04:00
parent 4a7c6241fa
commit b2010f3842
2 changed files with 13 additions and 1 deletions

View File

@ -85,7 +85,7 @@
;; special case `for/list'
[((val acc ...)
((~and inner-body (if e1 e2 e3:id)))
(null actuals ...))
(~and (null actuals ...) (null-exp . _)))
#:when (free-identifier=? #'val #'e3)
(let ([ts (for/list ([ac (in-syntax #'(actuals ...))]
[f (in-syntax #'(acc ...))])
@ -99,6 +99,9 @@
[(tc-result1: (and t (Listof: _))) t]
[_ #f])
(generalize -Null))])
;; this check is needed because the type annotation may come
;; from `for/fold` and it won't necessarily be a list type
(tc-expr/check #'null-exp (ret acc-ty))
(define-values (fun-results body-results)
(tc/rec-lambda/check args body lp (cons acc-ty ts) expected))
(add-typeof-expr lam fun-results)

View File

@ -3113,6 +3113,15 @@
(define f (lambda () 'hi))
(f))
#:msg "cannot apply function of type Procedure"]
;; PR 13259
[tc-err
(let ()
(: y String)
(define y (for/fold: ((x : String null)) ((v : String null)) x))
y)
#:ret (ret -String)
#:msg "expected: String.*given: Null"]
)
(test-suite