Skip to content
Snippets Groups Projects
Commit df1a39b9 authored by pmai's avatar pmai
Browse files

Entomotomy Bug: pcl-error-reporting-unhelpful-on-missing-primary-method

Merged patches and ideas by Gerd Moellmann and Christophe Rhodes to improve
error reporting on missing applicable primary methods for standard method-
combination to report the arguments that were passed to the GF in question.
parent 13d6fbc3
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/braid.lisp,v 1.27 2002/11/22 00:39:55 pmai Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/braid.lisp,v 1.28 2002/12/18 19:16:27 pmai Exp $")
;;; ;;;
;;; Bootstrapping the meta-braid. ;;; Bootstrapping the meta-braid.
;;; ;;;
...@@ -621,6 +621,20 @@ when called with arguments ~S." ...@@ -621,6 +621,20 @@ when called with arguments ~S."
:arguments args) :arguments args)
(apply generic-function args)) (apply generic-function args))
(define-condition no-primary-method (no-applicable-method)
()
(:report (lambda (condition stream)
(format stream "Generic function ~S~%~
No primary method given arguments ~S"
(no-applicable-method-function condition)
(no-applicable-method-arguments condition)))))
(defmethod no-primary-method ((generic-function standard-generic-function)
&rest args)
(cerror "Try again." 'no-primary-method
:function generic-function :arguments args)
(apply generic-function args))
(define-condition no-next-method (type-error) (define-condition no-next-method (type-error)
((method :reader no-next-method-method :initarg :method) ((method :reader no-next-method-method :initarg :method)
(arguments :reader no-next-method-arguments :initarg :arguments)) (arguments :reader no-next-method-arguments :initarg :arguments))
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/combin.lisp,v 1.11 2002/08/26 02:23:11 pmai Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/combin.lisp,v 1.12 2002/12/18 19:16:28 pmai Exp $")
;;; ;;;
(in-package :pcl) (in-package :pcl)
...@@ -175,14 +175,22 @@ ...@@ -175,14 +175,22 @@
(multiple-value-bind (nreq applyp metatypes nkeys arg-info) (multiple-value-bind (nreq applyp metatypes nkeys arg-info)
(get-generic-function-info gf) (get-generic-function-info gf)
(declare (ignore nreq nkeys arg-info)) (declare (ignore nreq nkeys arg-info))
(let ((ll (make-fast-method-call-lambda-list metatypes applyp)) (let ((ll (make-fast-method-call-lambda-list metatypes applyp)))
;; When there are no primary methods and a next-method call occurs (cond
;; effective-method is (error "No mumble..") and the defined ;; When there are no primary methods and a next-method call
;; args are not used giving a compiler warning. ;; occurs effective-method is (%no-primary-method <gf>),
(error-p (eq (first effective-method) 'error))) ;; which we define here to collect all gf arguments, to pass
`(lambda ,ll ;; those together with the GF to no-primary-method:
(declare (ignore ,@(if error-p ll '(.pv-cell. .next-method-call.)))) ((eq (first effective-method) '%no-primary-method)
,effective-method)))) `(lambda (.pv-cell. .next-method-call. &rest .args.)
(declare (ignore .pv-cell. .next-method-call.))
(flet ((%no-primary-method (gf)
(apply #'no-primary-method gf .args.)))
,effective-method)))
(t
`(lambda ,ll
(declare (ignore .pv-cell. .next-method-call.))
,effective-method))))))
(defun expand-emf-call-method (gf form metatypes applyp env) (defun expand-emf-call-method (gf form metatypes applyp env)
(declare (ignore gf metatypes applyp env)) (declare (ignore gf metatypes applyp env))
...@@ -340,8 +348,14 @@ ...@@ -340,8 +348,14 @@
primary (reverse primary) primary (reverse primary)
around (reverse around)) around (reverse around))
(cond ((null primary) (cond ((null primary)
`(error "No primary method for the generic function ~S." ;;
',generic-function)) ;; This form is recognized by expand-effective-method-function,
;; which provides a definition for %no-primary-method that
;; collects all gf arguments, and passes them together with the
;; generic function to no-primary-method for more informative
;; error reporting.
;;
`(%no-primary-method ',generic-function))
((and (null before) (null after) (null around)) ((and (null before) (null after) (null around))
;; ;;
;; By returning a single call-method `form' here we enable an ;; By returning a single call-method `form' here we enable an
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/generic-functions.lisp,v 1.15 2002/11/22 01:05:23 pmai Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/generic-functions.lisp,v 1.16 2002/12/18 19:16:28 pmai Exp $")
;;; ;;;
(in-package :pcl) (in-package :pcl)
...@@ -769,6 +769,8 @@ ...@@ -769,6 +769,8 @@
(defgeneric no-applicable-method (generic-function &rest args)) (defgeneric no-applicable-method (generic-function &rest args))
; (t) ; (t)
(defgeneric no-primary-method (generic-function &rest args))
(defgeneric reader-method-class (class direct-slot &rest initargs)) (defgeneric reader-method-class (class direct-slot &rest initargs))
; (slot-class t) ; (slot-class t)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment