Function: edebug-b/a-error

edebug-b/a-error is a byte-compiled function defined in edebug.el.gz.

Signature

(edebug-b/a-error FUNC)

Documentation

Throw an error for an invalid call of FUNC.

FUNC is expected to be edebug-before or edebug-after.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/edebug.el.gz
;; The following versions of `edebug-before' and `edebug-after' exist
;; to handle the error which occurs if either of them gets called
;; without an enclosing `edebug-enter'.  This can happen, for example,
;; when a macro mistakenly has a `form' element in its edebug spec,
;; and it additionally, at macro-expansion time, calls `eval',
;; `apply', or `funcall' (etc.) on the corresponding argument.  This
;; is intended to fix bug#65620.

(defun edebug-b/a-error (func)
  "Throw an error for an invalid call of FUNC.
FUNC is expected to be `edebug-before' or `edebug-after'."
  (let (this-macro
        (n 0)
        bt-frame)
    (while (and (setq bt-frame (backtrace-frame n))
                (not (and (car bt-frame)
                          (memq (cadr bt-frame)
                                '(macroexpand macroexpand-1)))))
      (setq n (1+ n)))
    (when bt-frame
      (setq this-macro (caaddr bt-frame)))

    (error
     (concat "Invalid call to `" (symbol-name func) "'"
             (if this-macro
                 (concat ".  Is the edebug spec for `"
                         (symbol-name this-macro)
                         "' correct?")
               ""   ; Not sure this case is possible (ACM, 2023-09-02)
               )))))