From b050c4f1922ea9789ebf99adc70a9b06b8c9dc80 Mon Sep 17 00:00:00 2001 From: "William J. Bowman" Date: Sat, 3 Oct 2015 04:09:16 -0400 Subject: [PATCH] Better error messages for let, in certain cases --- stdlib/sugar.rkt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/stdlib/sugar.rkt b/stdlib/sugar.rkt index 92dcfd5..4802fac 100644 --- a/stdlib/sugar.rkt +++ b/stdlib/sugar.rkt @@ -119,7 +119,15 @@ #:attr id #'x #:attr expr #'e #:attr type (cond - [(attribute t) #'t] + [(attribute t) + ;; TODO: Code duplication in :: + (unless (type-check/syn? #'e #'t) + (raise-syntax-error + 'let + (format "Term ~a does not have expected type ~a. Inferred type was ~a" + (cur->datum #'e) (cur->datum #'t) (cur->datum (type-infer/syn #'e))) + #'e (quasisyntax/loc #'x (x e)))) + #'t] [(type-infer/syn #'e)] [else (raise-syntax-error @@ -137,6 +145,7 @@ (syntax-case syn () [(_ pf t) (begin + ;; TODO: Code duplication in let-clause pattern (unless (type-check/syn? #'pf #'t) (raise-syntax-error '::