Subject: bug#41745: 28.0.50; problem with json file and which-function on pretest an master

From: "Basil L. Contovounesios" <[email-masked]>
Date: Sun, 07 Jun 2020 13:23:14 +0100

Andrés Ramírez <[email-masked]> writes:

> I have an issue after opening a json file with pretest.  Going to end
> of file with M-> then M-x backward-delete-char. I get this:
>
> Debugger entered--Lisp error: (cl-assertion-failed ((or (= (point-min) (point-max)) (eq js--last-parse-pos (point))) nil))
>   cl--assertion-failed((or (= (point-min) (point-max)) (eq js--last-parse-pos (point))))
>   js--imenu-create-index()
>   imenu--make-index-alist(t)
>   which-function()
>   which-func-update-1(#<window 3 on sale_line_grammar.json>)
>   which-func-update()
>   apply(which-func-update nil)
>   timer-event-handler([t 0 0 500000 t which-func-update nil idle 0])
>
> I have tried to do the same with emacs -Q (But. I was not able of
> reproducing it).

Could you try commenting-out parts of your configuration, perhaps by
recursively bisecting it, to narrow down which parts of it give rise to
the error?

> Also I have tested the same with emacs26.3. And everything works ok.
>
> So my personal conclusion is that this is a regression (related to which-func.el).

That depends on who is causing the problem - it could be a third-party
package that you have installed, for example.  Until there is a clear
reproduction recipe it's hard to know for sure.

> So. I have not been able of reproducing it with emacs -Q. If needed I
> could share my dot emacs files.
>
> Just in Case this is the content of the file that causes the issue:
>
> //  TODO: code the #else; analize  it {before document better the keywords}
> #if ( ${saleline.is_service()} == 0 )
> ${saleline.supplier()}/${saleline.subcategory()}/${saleline.color()}/${saleline.size()}/${saleline.name()}/${saleline.unit()}
> #end
> #if ( ${saleline.is_service()} == "1" )
> ${saleline.supplier()}/${saleline.subcategory()}/${saleline.name()}
> #end

I'm confused; are these the entire contents of the file
sale_line_grammar.json that is mentioned in the backtrace?  Is this some
sort of templating syntax that is replaced with valid JSON later on?  If
so, this issue is more about js-mode or whichever other major mode you
may be using, rather than JSON.  What does C-h v major-mode RET tell you
when you're visiting this file?

I tried the following with both emacs-27 and master and didn't run into
any errors:

0. emacs -Q
1. C-x C-f /tmp/sale_line_grammar.json RET
2. M->
3. M-x delete-backward-char RET
4. C-x z z z z z z z z

-- 
Basil