From aceb4cade5c3b407da7133bdabf04a59f038c324 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 16 Jan 2017 00:34:06 -0800 Subject: defmeth uses new error reporting. * share/txr/stdlib/struct.tl (sys:defmeth): Removing checks from here. (defmeth): Add checks here with new functions which provide location info and warning deferral/supression. --- share/txr/stdlib/struct.tl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/share/txr/stdlib/struct.tl b/share/txr/stdlib/struct.tl index b1d0acfd..e3e711a4 100644 --- a/share/txr/stdlib/struct.tl +++ b/share/txr/stdlib/struct.tl @@ -241,13 +241,16 @@ ^[(fun umethod) ',slot ,*bound-args]) (defun sys:defmeth (type-sym name fun) - (let ((type (find-struct-type type-sym))) - (unless type - (throwf 'eval-error "~s: ~s isn't a struct type" 'defmeth type-sym)) - (static-slot-ensure type-sym name fun) - ^(meth ,type-sym ,name))) + (static-slot-ensure type-sym name fun) + ^(meth ,type-sym ,name)) -(defmacro defmeth (type-sym name arglist . body) +(defmacro defmeth (:form form type-sym name arglist . body) + (cond + ((not (bindable type-sym)) + (compile-error form "~s isn't a valid struct name" type-sym)) + ((not (find-struct-type type-sym)) + (compile-defr-warning form ^(struct-type . ,type-sym) + "definition of struct ~s not seen here" type-sym))) ^(sys:defmeth ',type-sym ',name (lambda ,arglist (block ,name ,*body)))) -- cgit v1.2.3