Fix for/fold typechecking on null accumulator
Closes PR 13259
This commit is contained in:
parent
7f8cf7a2ce
commit
0b3b1f5d94
|
@ -85,7 +85,7 @@
|
||||||
;; special case `for/list'
|
;; special case `for/list'
|
||||||
[((val acc ...)
|
[((val acc ...)
|
||||||
((~and inner-body (if e1 e2 e3:id)))
|
((~and inner-body (if e1 e2 e3:id)))
|
||||||
(null actuals ...))
|
(~and (null actuals ...) (null-exp . _)))
|
||||||
#:when (free-identifier=? #'val #'e3)
|
#:when (free-identifier=? #'val #'e3)
|
||||||
(let ([ts (for/list ([ac (in-syntax #'(actuals ...))]
|
(let ([ts (for/list ([ac (in-syntax #'(actuals ...))]
|
||||||
[f (in-syntax #'(acc ...))])
|
[f (in-syntax #'(acc ...))])
|
||||||
|
@ -99,6 +99,9 @@
|
||||||
[(tc-result1: (and t (Listof: _))) t]
|
[(tc-result1: (and t (Listof: _))) t]
|
||||||
[_ #f])
|
[_ #f])
|
||||||
(generalize -Null))])
|
(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)
|
(define-values (fun-results body-results)
|
||||||
(tc/rec-lambda/check args body lp (cons acc-ty ts) expected))
|
(tc/rec-lambda/check args body lp (cons acc-ty ts) expected))
|
||||||
(add-typeof-expr lam fun-results)
|
(add-typeof-expr lam fun-results)
|
||||||
|
|
|
@ -3113,6 +3113,15 @@
|
||||||
(define f (lambda () 'hi))
|
(define f (lambda () 'hi))
|
||||||
(f))
|
(f))
|
||||||
#:msg "cannot apply function of type Procedure"]
|
#: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
|
(test-suite
|
||||||
|
|
Loading…
Reference in New Issue
Block a user