www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 579815512eb2b49d4a1311bf5e4d3a1126624d5e
parent ce1bc6b90ffce51ee5fabb7e0c1255b0bb63c249
Author: Stephen Chang <stchang@ccs.neu.edu>
Date:   Wed, 20 Apr 2016 19:18:33 -0400

for/fold produces better err msg

Diffstat:
Mtapl/mlish.rkt | 6+++++-
Mtapl/tests/mlish-tests.rkt | 3+++
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tapl/mlish.rkt b/tapl/mlish.rkt @@ -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 diff --git a/tapl/tests/mlish-tests.rkt b/tapl/tests/mlish-tests.rkt @@ -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