From f2caa4b2936a2bdc25af46a882ba45da73b799a8 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 13 Feb 2014 00:00:11 -0500 Subject: [PATCH] Improve error messages from : annotation form Emit errors in terms of the original user-supplied syntax, not the helper macro syntax original commit: 36524740c873ba8c28202e9abc10adf0cf4618c6 --- .../typed-racket/base-env/colon.rkt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/colon.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/colon.rkt index bce93dc5..1ea1b74a 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/colon.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/colon.rkt @@ -31,14 +31,15 @@ (err stx "must be used in a definition context")] [(: id (~and kw :) . more:omit-parens) (add-disappeared-use #'kw) - (wrap stx #`(:-helper #,top-level? id more.type))] + (wrap stx #`(:-helper #,stx #,top-level? id more.type))] [(: id : . more) - (wrap stx #`(:-helper #,top-level? id . more))] - [(: e ...) (wrap stx #`(:-helper #,top-level? e ...))])) + (wrap stx #`(:-helper #,stx #,top-level? id . more))] + [(: e ...) + (wrap stx #`(:-helper #,stx #,top-level? e ...))])) (define-syntax (:-helper stx) (syntax-parse stx - [(_ top-level? i:id ty) + [(_ _ top-level? i:id ty) (unless (or (syntax-e #'top-level?) (identifier-binding #'i)) (tc-error/stx #'i @@ -48,9 +49,9 @@ (syntax-property (syntax/loc stx (begin (quote-syntax (:-internal i ty)) (#%plain-app values))) 'disappeared-use #'i)] - [(_ _ i:id x ...) + [(_ orig-stx _ i:id x ...) (case (syntax-length #'(x ...)) - [(1) (err stx "can only annotate identifiers with types" #'i)] - [(0) (err stx "missing type")] - [else (err stx "bad syntax (multiple types after identifier)")])])) + [(1) (err #'orig-stx "can only annotate identifiers with types" #'i)] + [(0) (err #'orig-stx "missing type")] + [else (err #'orig-stx "bad syntax (multiple types after identifier)")])]))