X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fdefmacro.lisp;h=a408ec98bc7069ce7e13b89d7493ade52755ff3d;hb=f59b6f1f0406f2bbcbec4fa712c0e6d5df06e737;hp=d45a27c0603bfc80e4e99eb73919240013d93978;hpb=cb83aa22932bf4b9bc74ac6f0fcd91db1702ad33;p=sbcl.git diff --git a/src/code/defmacro.lisp b/src/code/defmacro.lisp index d45a27c..a408ec9 100644 --- a/src/code/defmacro.lisp +++ b/src/code/defmacro.lisp @@ -43,7 +43,7 @@ ;; function, and report spurious warnings about ;; redefinition a macro as a function, and then ;; vice versa. - #-sb-xc-host #-sb-xc-host named-lambda (defmacro ,name) + #-sb-xc-host named-lambda #-sb-xc-host (defmacro ,name) (,whole ,environment) ,@local-decs ,new-body)) @@ -61,47 +61,43 @@ ;; the functional value." ,@(unless set-p '((declare (ignore lambda-list debug-name)))) - (ecase (info :function :kind name) - ((nil)) - (:function - ;; (remhash name *free-funs*) - (undefine-fun-name name) - (style-warn - "~S is being redefined as a macro when it was ~ - previously ~(~A~) to be a function." - name - (info :function :where-from name))) - (:macro) - (:special-form - (error "The special form ~S can't be redefined as a macro." - name))) - (clear-info :function :where-from name) - ;; FIXME: It would be nice to warn about DEFMACRO of an - ;; already-defined macro, but that's slightly hard to do - ;; because in common usage DEFMACRO is defined at compile - ;; time and then redefined at load time. We'd need to make a - ;; distinction between the defined-at-compile-time state and - ;; the defined-at-load-time state to make this work. (Trying - ;; to warn about duplicate DEFTYPEs runs into the same - ;; problem.) - #+nil (when (sb!xc:macro-function name) - ;; Someday we could check for macro arguments - ;; being incompatibly redefined. Doing this right - ;; will involve finding the old macro lambda-list - ;; and comparing it with the new one. - (style-warn "redefining ~S in DEFMACRO" name)) - (setf (sb!xc:macro-function name) definition - (fdocumentation name 'function) doc) - ,(when set-p - `(case (widetag-of definition) - (#.sb!vm:closure-header-widetag - (setf (%simple-fun-arglist (%closure-fun definition)) - lambda-list - (%simple-fun-name (%closure-fun definition)) - debug-name)) - (#.sb!vm:simple-fun-header-widetag - (setf (%simple-fun-arglist definition) lambda-list - (%simple-fun-name definition) debug-name)))) + (with-single-package-locked-error () + (case (info :function :kind name) + (:function + (let ((where-from (info :function :where-from name))) + (when (eq :defined where-from) + (assert-symbol-home-package-unlocked name "defining ~S as a macro")) + (style-warn + "~S is being redefined as a macro when it was ~ + previously ~(~A~) to be a function." + name where-from)) + (undefine-fun-name name)) + (:special-form + (error "The special form ~S can't be redefined as a macro." + name))) + (clear-info :function :where-from name) + + ;; FIXME: It would be nice to warn about DEFMACRO of an + ;; already-defined macro, but that's slightly hard to do + ;; because in common usage DEFMACRO is defined at compile + ;; time and then redefined at load time. We'd need to make a + ;; distinction between the defined-at-compile-time state and + ;; the defined-at-load-time state to make this work. (Trying + ;; to warn about duplicate DEFTYPEs runs into the same + ;; problem.) + #+nil + (when (sb!xc:macro-function name) + ;; Someday we could check for macro arguments + ;; being incompatibly redefined. Doing this right + ;; will involve finding the old macro lambda-list + ;; and comparing it with the new one. + (style-warn "redefining ~/sb-impl::print-symbol-with-prefix/ ~ + in DEFMACRO" name)) + (setf (sb!xc:macro-function name) definition) + ,(when set-p + `(setf (%fun-doc definition) doc + (%fun-lambda-list definition) lambda-list + (%fun-name definition) debug-name))) name)))) (progn (def (:load-toplevel :execute) #-sb-xc-host t #+sb-xc-host nil)