for/fold produces better err msg

This commit is contained in:
Stephen Chang 2016-04-20 19:18:33 -04:00
parent ce1bc6b90f
commit 579815512e
2 changed files with 8 additions and 1 deletions

View File

@ -924,7 +924,11 @@
#:with ([e- (ty)] ...) (⇑s (e ...) as Sequence)
#:with [(acc- x- ...) body- ty_body]
(infer/ctx+erase #'([acc : ty_init][x : ty] ...) #'body)
#:when (typecheck? #'ty_body #'ty_init)
#:fail-unless (typecheck? #'ty_body #'ty_init)
(type-error #:src stx
#:msg
"for/fold: Type of body and initial accumulator must be the same, given ~a and ~a"
#'ty_init #'ty_body)
( (for/fold ([acc- init-]) ([x- e-] ...) body-) : ty_body)])
(define-typed-syntax for/hash

View File

@ -390,6 +390,9 @@
(check-type RT2 : (→/test {X Y} Y X (List X) (RecoTest X Y)))
(check-type RT3 : (→/test X Y (RecoTest X Y)))
(typecheck-fail (for/fold ([x 1]) () "hello")
#:with-msg "for/fold: Type of body and initial accumulator must be the same, given Int and String")
; ext-stlc tests --------------------------------------------------
; tests for stlc extensions