PCL::*OPTIMIZE-GF-CALLS-P* bug when GF name is shadowed lexically

Madhu <[email protected]>
Newsgroups gmane.lisp.cmucl.devel
Message-ID <[email protected]>
CMUCL does not correctly handle FLETs in DEFMETHOD bodies which use the
same name as that of the generic function.
An example might be:

; (setq pcl::*optimize-gf-calls-p* t)
(defmethod foo (bar var) (format t "GENERICFOO ~S, ~S.%" bar var))

(defclass fnarr ()())

(defmethod foo ((bar fnarr) var)
  (flet ((foo (&optional arg)
	   (foo var (class-of arg)))) ; gf FOO call
    (foo bar))) ; local function FOO call

;; (incorrect) Error when evaluating 
(foo (make-instance 'fnarr) t)


Perhaps the immediate symptom can be treated in WALK-METHOD-LAMBDA as
follows? -- Madhu

--- pcl/boot.lisp~
+++ pcl/boot.lisp
@@ -1177,7 +1177,8 @@
 		    (optimize-slot-writer form required-parameters slots env))
 		   ;;
 		   ((and (valid-function-name-p (car form))
-			 (info-gf-name-p (car form)))
+			 (info-gf-name-p (car form))
+			 (not (walker::environment-function env (car form))))
 		    (optimize-gf-call form required-parameters calls env))
 		   (t
 		    form))))


	   ((and (valid-function-name-p (car form))
		 (info-gf-name-p (car form)))
	    (optimize-gf-call form required-parameters calls env))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.