Subject: bug#24753: 26.0.50; Error using Edebug on code that uses cl-defmethod

From: Dmitry Gutov <[email-masked]>
Date: Tue, 11 Apr 2017 15:16:47 +0300

On 21.10.2016 18:15, Gemini Lasswell wrote:
> Edebug gets confused after instrumenting multiple methods with the same
> name created by cl-defgeneric and cl-defmethod. To reproduce, save the
> following bit of code (which is an excerpt from cl-generic-tests.el)
> to bug.el:
> 
> (require 'cl-generic)
> 
> (fmakunbound 'foo)
> (cl-defgeneric foo (x y))
> (cl-defgeneric (setf foo) (v y z) "My generic doc.")
> (cl-defmethod (setf foo) (v (y t) z) (list v y z))
> (cl-defmethod (setf foo) (v (_y (eql 4)) z) (list v "four!" z))
> 
> (defun foo-bug ()
>    (message "%s" (setf (foo 'a 'b) 'v)))
> 
> (foo-bug)
> 
> Steps to reproduce:
> 1. emacs -Q
> 2. C-x C-f bug.el RET
> 3. M-x edebug-all-defs RET
> 4. M-x eval-buffer RET
> 5. g
> 
> Result: edebug--display: Args out of range: [44 51 61 62], 4

I can reproduce this scenario, but I don't recall seeing this exact 
error in practice.

TBH, I'm not sure what (setf foo) does in the NAME slot.

A similar scenario with existing functions leads to a related problem:

1. Search for the definitions of semantic-symref-perform-search.

2. Instrument the one in semantic/symref/grep.el and some other one, 
like semantic/symref/cscope.el (the order is important).

3. Make sure there are no index files belonging to any tools in the 
Emacs root directory, so that the Grep tool will be used for search.

4. Type M-x xref-find-references, input something.

5. See edebug jump in the definition in cscope.el, even though the TOOL 
argument is ...-grep. As I step through it, it quickly gives up with 
"Source has changed".

Your patch seems to fix that as well. I hope someone else more familiar 
with edebug will take a look at it soon.