Subject: Re: bug#59498: 29.0.50; c++-ts-mode get wrong-type-argument error when enabled

From: Eason Huang <[email-masked]>
Date: Wed, 23 Nov 2022 18:53:29 +0800

Daniel Martín <[email-masked]> writes:

> Eason Huang <[email-masked]> writes:
>
>> Hi emacs-devel,
>>
>> I just tried the c++-ts-mode, but it didn't worked.
>>
>> steps to reproduce:
>>
>> 1. luanch Emacs with emacs -Q
>> 2. C-x, C-f ~/test.cpp
>> 3. M-x, toggle-debug-on-error
>> 4. M-x, c++-ts-mode, now you will get the errors as bellow:
>>
>> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>>   treesit-ready-p(cpp)
>>   c++-ts-mode()
>>   funcall-interactively(c++-ts-mode)
>>   command-execute(c++-ts-mode record)
>>   execute-extended-command(nil "c++-ts-mode" "c++-ts")
>>   funcall-interactively(execute-extended-command nil "c++-ts-mode" "c++-ts")
>>   command-execute(execute-extended-command)
>>
>> By the way, python-ts-mode works well.
>>
>> I builded Emacs 29.0.50 with this commit:
>> https://github.com/emacs-mirror/emacs/commit/057901f55ad12ebbc9cf092dd6ad0f02539849f9
>
> Could you try an Emacs build that contains commit c69858b3f0?  This is
> the same bug as bug#59497.  Thanks.

Hi Daniel,

I build the latest commit(9f4306cd) and try it a again. This issue have
been fixed.

But when I try to indent code,
it will raise the error (Wrong type argument: stringp, nil) again.
It should be a different bug.

Steps to reproduce:

After the step 4, try to type the code as below:

int main(){
<-- put you cursor at the first colum 1, and then hit TAB(indent-for-tab-command)

}

after you hit TAB at the above code, you will get the backtrace error as
below:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  looking-at(nil t)
  #f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>)(nil #<treesit-node (compound_statement) in 11-15> 13)
  #f(compiled-function (fn) #<bytecode 0x188c898311f019af>)(#f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>))
  mapcar(#f(compiled-function (fn) #<bytecode 0x188c898311f019af>) (#f(compiled-function (n parent &rest _) #<bytecode 0x149caa867664fee9>) #f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>)))
  #f(compiled-function (node parent bol &rest _) #<bytecode -0xb869f433d8fc770>)(nil #<treesit-node (compound_statement) in 11-15> 13)
  treesit--simple-indent-eval(((and (parent-is "comment") comment-end) nil #<treesit-node (compound_statement) in 11-15> 13))
  treesit-simple-indent(nil #<treesit-node (compound_statement) in 11-15> 13)
  treesit--indent-1()
  treesit-indent()
  indent-according-to-mode()
  electric-indent-post-self-insert-function()
  newline(nil 1)
  funcall-interactively(newline nil 1)
  command-execute(newline)

-- 
Eason Huang