From 7d581fab3987ff7cd8a4633b5db2cfd0126f54c0 Mon Sep 17 00:00:00 2001
From: Nikodemus Siivola <nikodemus@random-state.net>
Date: Thu, 8 Jul 2004 18:29:53 +0000
Subject: [PATCH] 0.8.12.26: 99 bugs in SB-PCL, take one down, pass it
 around...            * Fixed #167: illegal syntax in method
 bodies now signals a                more informative error.
            * No test, tough, since it would be horribly
 brittle for very                little actual gain.

---
 BUGS              |   14 --------------
 NEWS              |    2 ++
 src/pcl/walk.lisp |   14 ++++++++++----
 version.lisp-expr |    2 +-
 4 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/BUGS b/BUGS
index 506e11a..10fb8d1 100644
--- a/BUGS
+++ b/BUGS
@@ -481,20 +481,6 @@ WORKAROUND:
 
   This is probably the same bug as 216
 
-167:
-  In sbcl-0.7.3.11, compiling the (illegal) code 
-    (in-package :cl-user)
-    (defmethod prove ((uustk uustk))
-      (zap ((frob () nil))
-        (frob)))
-  gives the (not terribly clear) error message
-    ; caught ERROR:
-    ;   (during macroexpansion of (DEFMETHOD PROVE ...))
-    ; can't get template for (FROB NIL NIL)
-  The problem seems to be that the code walker used by the DEFMETHOD
-  macro is unhappy with the illegal syntax in the method body, and
-  is giving an unclear error message.
-
 173:
   The compiler sometimes tries to constant-fold expressions before
   it checks to see whether they can be reached. This can lead to 
diff --git a/NEWS b/NEWS
index a813f36..1fa748b 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@ changes in sbcl-0.8.13 relative to sbcl-0.8.12:
   * fixed bug: initialization of condition class metaobjects no longer
     causes an instance of the condition to be created. (reported by Marco
     Baringer)
+  * fixed bug #167: errors signalled due to illegal syntax in method 
+    bodies are now more legible.
   * fixed bug #338: instances of EQL-SPECIFIER are now valid type
     designators and can hence be used with TYPEP.
   * fixed bug #333: CHECK-TYPE now ensures that the type error
diff --git a/src/pcl/walk.lisp b/src/pcl/walk.lisp
index ac68857..dcdd282 100644
--- a/src/pcl/walk.lisp
+++ b/src/pcl/walk.lisp
@@ -358,13 +358,19 @@
   `(eval-when (:load-toplevel :execute)
      (setf (get-walker-template-internal ',name) ',template)))
 
-(defun get-walker-template (x)
+(defun get-walker-template (x context)
   (cond ((symbolp x)
          (get-walker-template-internal x))
 	((and (listp x) (eq (car x) 'lambda))
 	 '(lambda repeat (eval)))
 	(t
-	 (error "can't get template for ~S" x))))
+	 ;; FIXME: In an ideal world we would do something similar to
+	 ;; COMPILER-ERROR here, replacing the form within the walker
+	 ;; with an error-signalling form. This is slightly less
+	 ;; pretty, but informative non the less. Best is the enemy of
+	 ;; good, etc.
+	 (error "Illegal function call in method body:~%  ~S"
+		context))))
 
 ;;;; the actual templates
 
@@ -452,7 +458,7 @@
 		newform)))
 	 (t
 	  (let* ((fn (car newform))
-		 (template (get-walker-template fn)))
+		 (template (get-walker-template fn newform)))
 	    (if template
 		(if (symbolp template)
 		    (funcall template newform context env)
@@ -623,7 +629,7 @@
 		   (cdr body) fn env doc-string-p declarations)))
 	((and form
 	      (listp form)
-	      (null (get-walker-template (car form)))
+	      (null (get-walker-template (car form) form))
 	      (progn
 		(multiple-value-setq (new-form macrop)
 				     (sb-xc:macroexpand-1 form env))
diff --git a/version.lisp-expr b/version.lisp-expr
index 8ad3e76..0de7ade 100644
--- a/version.lisp-expr
+++ b/version.lisp-expr
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.8.12.25"
+"0.8.12.26"
-- 
1.7.10.4