Ticket #1079 (new defect)

Opened 19 months ago

Last modified 19 months ago

defgeneric :method declare should not signal a program-error.

Reported by: pjb@… Owned by:
Priority: normal Milestone:
Component: Compiler Version: 1.8
Keywords: misleading error message Cc:

Description

The compiler signals an error on the following defgeneric, complaining about the declaration in the :method. But declarations are syntactically legal there, according to clhs defgeneric.

(defgeneric make-collector        (result-type)
  (:method (unexpected-result-type)
    (declare (ignore unexpected-result-type))
    (lambda (&optional set element)
      (declare (ignore set element))
      (values))))

;; clhs defgeneric:
;;
;; method-description::= (:method method-qualifier* specialized-lambda-list [[declaration* | documentation]] form*) 

#|
While compiling (make-collector (t)) :
declare not expected in (declare
                         (ignore unexpected-result-type)).
   [Condition of type ccl::compile-time-program-error]

Restarts:
 0: [continue] continue compilation ignoring this form
 1: [continue] continue compilation ignoring this form
 2: [retry-load] Retry loading #P"/home/pjb/src/public/lisp/common-lisp/cesarum/index-set.lisp"
 3: [skip-load] Skip loading #P"/home/pjb/src/public/lisp/common-lisp/cesarum/index-set.lisp"
 4: [load-other] Load other file instead of #P"/home/pjb/src/public/lisp/common-lisp/cesarum/index-set.lisp"
 5: [*abort] Return to SLIME's top level.
 --more--

Backtrace:
  0: ((:internal ccl::nx1-compile-lambda) #<ccl::compile-time-program-error #x3020024B586D>)
  1: (signal #<ccl::compile-time-program-error #x3020024B586D>)
  2: (ccl::%error #<ccl::compile-time-program-error #x3020024B586D> nil 17464334935162)
  3: (cerror "continue compilation ignoring this form" #<ccl::compile-time-program-error #x3020024B586D>)
  4: ((:internal ccl::nx1-compile-lambda) #<ccl::compile-time-program-error #x3020024B586D>)
  5: (signal #<ccl::compile-time-program-error #x3020024B586D>)
  6: (ccl::%error #<ccl::compile-time-program-error #x3020024B586D> nil 17464334935181)
  7: (ccl::nx-error "~S not expected in ~S." declare (declare (ignore unexpected-result-type)))
  8: (ccl::nx1-misplaced :value (declare (ignore unexpected-result-type)) #<ccl::lexical-environment #x3020024B623D..
  9: (ccl::nx1-combination :value (declare (ignore unexpected-result-type)) #<ccl::lexical-environment #x3020024B62..
 10: (ccl::nx1-transformed-form :value (declare (ignore unexpected-result-type)) #<ccl::lexical-environment #x30200..
 11: (ccl::nx1-typed-form :value (declare (ignore unexpected-result-type)) #<ccl::lexical-environment #x3020024B623..
 12: (ccl::nx1-form :value (declare (ignore unexpected-result-type)) #<ccl::lexical-environment #x3020024B623D>)
 13: (ccl::nx1-arglist ((unexpected-result-type) (declare (ignore unexpected-result-type)) (lambda (&optional set e..
 14: (ccl::nx1-call-form :return :method nil ((unexpected-result-type) (declare (ignore unexpected-result-type)) (l..
 15: (ccl::nx1-call :return :method ((unexpected-result-type) (declare (ignore unexpected-result-type)) (lambda (&o..
 16: (ccl::nx1-typed-call :return :method ((unexpected-result-type) (declare (ignore unexpected-result-type)) (lamb..
 17: (ccl::nx1-combination :return (:method (unexpected-result-type) (declare (ignore unexpected-result-type)) (lam..
 18: (ccl::nx1-transformed-form :return (:method (unexpected-result-type) (declare (ignore unexpected-result-type))..
 19: (ccl::nx1-typed-form :return (:method (unexpected-result-type) (declare (ignore unexpected-result-type)) (lamb..
 20: (ccl::nx1-form :return (:method (unexpected-result-type) (declare (ignore unexpected-result-type)) (lambda (&o..
 21: (ccl::nx1-env-body :return ((:method (unexpected-result-type) (declare (ignore unexpected-result-type)) (lambd..
 22: (ccl::nx1-flet :return (flet ((call-next-method (&rest #1=#:g26509) (declare (dynamic-extent #1#)) (if #1# (ap..
 23: (ccl::nx1-combination :return (flet ((call-next-method (&rest #1=#:g26509) (declare (dynamic-extent #1#)) (if ..
 24: (ccl::nx1-transformed-form :return (flet ((call-next-method (&rest #1=#:g26509) (declare (dynamic-extent #1#))..
 25: (ccl::nx1-typed-form :return (flet ((call-next-method (&rest #1=#:g26509) (declare (dynamic-extent #1#)) (if #..
 26: (ccl::nx1-form :return (flet ((call-next-method (&rest #1=#:g26509) (declare (dynamic-extent #1#)) (if #1# (ap..
 27: (ccl::nx1-block :return (block make-collector (flet ((call-next-method (&rest #1=#:g26509) (declare (dynamic-e..
 28: (ccl::nx1-combination :return (block make-collector (flet ((call-next-method (&rest #1=#:g26509) (declare (dyn..
 29: (ccl::nx1-transformed-form :return (block make-collector (flet ((call-next-method (&rest #1=#:g26509) (declare..
 30: (ccl::nx1-typed-form :return (block make-collector (flet ((call-next-method (&rest #1=#:g26509) (declare (dyna..
 31: (ccl::nx1-form :return (block make-collector (flet ((call-next-method (&rest #1=#:g26509) (declare (dynamic-ex..
 32: (ccl::nx1-env-body :return ((block make-collector (flet ((call-next-method (&rest #1=#:g26509) (declare (dynam..
 33: (ccl::nx1-lambda (result-type) ((block make-collector (flet ((call-next-method (&rest #1=#:g26509) (declare (d..
 34: (ccl::nx1-compile-lambda (make-collector (t)) (lambda (ccl::&method #2=#:next-method-context result-type) (dec..
 35: (ccl::nx1-ref-inner-function make-collector (lambda (ccl::&method #2=#:next-method-context result-type) (decla..
 36: (ccl::nx1-nfunction :value (ccl:nfunction make-collector (lambda (ccl::&method #2=#:next-method-context result..
 37: (ccl::nx1-combination :value (ccl:nfunction make-collector (lambda (ccl::&method #2=#:next-method-context resu..
 38: (ccl::nx1-transformed-form :value (ccl:nfunction make-collector (lambda (ccl::&method #2=#:next-method-context..
 39: (ccl::nx1-typed-form :value (ccl:nfunction make-collector (lambda (ccl::&method #2=#:next-method-context resul..
 40: (ccl::nx1-form :value (ccl:nfunction make-collector (lambda (ccl::&method #2=#:next-method-context result-type..
 41: (ccl::nx1-arglist ((ccl:nfunction make-collector (lambda (ccl::&method #2=#:next-method-context . #3=(result-t..
 42: (ccl::nx1-call-form :value ccl::ensure-method nil ('make-collector (list t) :function (ccl:nfunction make-coll..
 43: (ccl::nx1-call :value ccl::ensure-method ('make-collector (list t) :function (ccl:nfunction make-collector (la..
 44: (ccl::nx1-typed-call :value ccl::ensure-method ('make-collector (list t) :function (ccl:nfunction make-collect..
 45: (ccl::nx1-combination :value (ccl::ensure-method 'make-collector (list t) :function (ccl:nfunction make-collec..
 46: (ccl::nx1-transformed-form :value (ccl::ensure-method 'make-collector (list t) :function (ccl:nfunction make-c..
 47: (ccl::nx1-typed-form :value (ccl::ensure-method 'make-collector (list t) :function (ccl:nfunction make-collect..
 48: (ccl::nx1-typed-var-initform #S(ccl::pending-declarations :vdecls nil :fdecls nil :mdecls nil) #:g26508 (ccl::..
 49: (ccl::nx1-let* :return (let* ((#4=#:g26508 (ccl::ensure-method 'make-collector (list t) :function (ccl:nfuncti..
 50: (ccl::nx1-combination :return (let* ((#4=#:g26508 (ccl::ensure-method 'make-collector (list t) :function (ccl:..
 51: (ccl::nx1-transformed-form :return (let* ((#4=#:g26508 (ccl::ensure-method 'make-collector (list t) :function ..
 52: (ccl::nx1-typed-form :return (let* ((#4=#:g26508 (ccl::ensure-method 'make-collector (list t) :function (ccl:n..
 53: (ccl::nx1-form :return (let* ((#4=#:g26508 (ccl::ensure-method 'make-collector (list t) :function (ccl:nfuncti..
 54: (ccl::nx1-catch-body :return ((let* ((#4=#:g26508 (ccl::ensure-method 'make-collector (list t) :function (ccl:..
 55: (ccl::nx1-compiler-let :return (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-collector (t)))) (let*..
 56: (ccl::nx1-combination :return (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-collector (t)))) (let* ..
 57: (ccl::nx1-transformed-form :return (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-collector (t)))) (..
 58: (ccl::nx1-typed-form :return (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-collector (t)))) (let* (..
 59: (ccl::nx1-form :return (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-collector (t)))) (let* ((#4=#:..
 60: (ccl::nx1-progn :return (progn (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-collector (t)))) (let*..
 61: (ccl::nx1-combination :return (progn (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-collector (t))))..
 62: (ccl::nx1-transformed-form :return (progn (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-collector (..
 63: (ccl::nx1-typed-form :return (progn (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-collector (t)))) ..
 64: (ccl::nx1-form :return (progn (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-collector (t)))) (let* ..
 65: (ccl::nx1-env-body :return ((progn (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-collector (t)))) (..
 66: (ccl::nx1-lambda nil ((progn (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-collector (t)))) (let* (..
 67: (ccl::nx1-compile-lambda nil (lambda nil (progn (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-colle..
 68: (ccl::compile-named-function (lambda nil (progn (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-colle..
 69: (ccl::cheap-eval-function nil (lambda nil (progn (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-coll..
 70: (ccl::cheap-eval-in-environment (ccl:compiler-let ((ccl::*nx-method-warning-name* '(make-collector (t)))) (let..
 71: ((:internal ccl::with-compilation-unit-body ccl::load-from-stream))
 72: (ccl::call-with-compilation-unit #<ccl:compiled-lexical-closure (:internal ccl::with-compilation-unit-body ccl..
 73: (ccl::load-from-stream #<basic-file-character-input-stream ("/home/pjb/src/git/public/lisp/common-lisp/cesarum..
 74: (ccl::%load #P"/home/pjb/src/git/public/lisp/common-lisp/cesarum/index-set.lisp" nil nil :error :default)
 75: (load #P"/home/pjb/src/public/lisp/common-lisp/cesarum/index-set.lisp" :verbose nil :print nil :if-does-not-ex..
 76: (swank:load-file "/home/pjb/src/public/lisp/common-lisp/cesarum/index-set.lisp")
 77: (ccl::call-check-regs swank:load-file "/home/pjb/src/public/lisp/common-lisp/cesarum/index-set.lisp")
 78: (ccl::cheap-eval (swank:load-file "/home/pjb/src/public/lisp/common-lisp/cesarum/index-set.lisp"))
 79: (swank:eval-for-emacs (swank:load-file "/home/pjb/src/public/lisp/common-lisp/cesarum/index-set.lisp") "\"COM...
 80: ((:internal swank::spawn-worker-thread))
 81: (swank-backend:call-with-debugger-hook #<Compiled-function swank:swank-debugger-hook #x302001C5D52F> #<Compile..
 82: (swank-backend:call-with-debugger-hook #<Compiled-function swank:swank-debugger-hook #x302001C5D52F> #<Compile..
 83: ((:internal swank::spawn-worker-thread))
 84: (swank::call-with-bindings ((*standard-output* . #1=#<swank-backend::slime-output-stream #x302001F1D9AD>) (*st..
 85: ((:internal swank::spawn-worker-thread))
 86: (swank::call-with-bindings ((*print-pretty*) (*print-level*) (*print-length*) (*print-circle* . t) (*print-cas..
 87: ((:internal swank::spawn-worker-thread))
 88: (ccl::run-process-initial-form #<process worker(3667) [Active] #x30200233264D> (#<ccl:compiled-lexical-closure..
 89: ((:internal (ccl::%process-preset-internal (ccl:process))) #<process worker(3667) [Active] #x30200233264D> (#<..
 90: ((:internal ccl::thread-make-startup-function))
|#

Change History

comment:1 Changed 19 months ago by pjb@…

  • Keywords misleading error message added; defgeneric :method declare removed
  • Component changed from ANSI CL Compliance to Compiler

Ok, the problem is not in signaling a program-error, there is indeed a program-error in there.

The problem is in the error message reported, which loses information and doesn't allow the correct identification of the erroneous form.

There was a defgeneric make-collector and a defmethod make-collector and the program-error was in the alter form, but there was no way to know it from the error message.

Instead of reporting "While compiling (make-collector (t)) :", report "While compiling (defmethod make-collector (t)) :".

Note: See TracTickets for help on using tickets.