From 6cdc5fb720cb69a9c6c541632e0e97bd571f1b23 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 9 Jul 2013 17:47:34 -0400 Subject: [PATCH] Improve several type error messages In particular, improve the syntax reported when the method arity is wrong. --- .../typed-racket/typecheck/check-class-unit.rkt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt index 3655c495e3..f1833752a3 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt @@ -186,7 +186,7 @@ super-methods super-augments)) (values super-inits super-fields super-methods super-augments)] [(tc-result1: t) - (tc-error/expr "expected a superclass but got ~a" t + (tc-error/expr "expected a superclass but got value of type ~a" t #:stx #'cls.superclass-expr) ;; FIXME: is this the right thing to do? (values null null null null)])) @@ -994,8 +994,11 @@ (define annotated-self-param (type-ascription-property #'self-param self-type)) #`(let-values ([(#,(syntax-property #'meth-name 'type-label method-type)) - (#%plain-lambda (#,annotated-self-param id ...) - body ...)]) + ;; attach source location to the lambda in order to + ;; obtain better error messages for arity errors + #,(quasisyntax/loc stx + (#%plain-lambda (#,annotated-self-param id ...) + body ...))]) m)] [(let-values ([(meth-name:id) (let-values (((core:id) @@ -1005,9 +1008,11 @@ m) #`(let-values ([(#,(syntax-property #'meth-name 'type-label method-type)) #,(syntax-property - #'(let-values (((core) - (#%plain-lambda (param ...) - core-body ...))) + #`(let-values (((core) + ;; see comment above + #,(quasisyntax/loc stx + (#%plain-lambda (param ...) + core-body ...)))) method-body ...) 'kw-lambda #t)]) m)]