Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
imenu crash when a comment contains 'in' #7844
Original bug ID: 7844
imenu in Emacs crashes when a comment contains the word 'in'. This also affects tuareg-mode.
Steps to reproduce
Create an ocaml buffer with the following contents:
And run M-x imenu.
Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
Note that tuareg-imenu-create-index is an alias for caml-create-index-function.
Comment author: wyuenho
Further debugging shows that it's not that there's an "in" in a comment that causes this issue, but that the search doesn't stop when the beginning of the buffer is reached. So the code the is looking at the last regular expression match while expecting data from the current match, in which there isn't any.
Comment author: wilfred
I think the problem is this:
caml-create-index-function calls caml-prev-index-position-function, which is intended to search backwards until it finds the previous definition suitable for imenu.
However, because caml-in-comment-p incorrectly returns nil, we think we've found a match. The bad match data is just a side effect of caml-prev-index-position-function returning a number when it's inside the comment.