Subject: bug#64830: 30.0.50 C++ treesitter mode no coloration

From: Eli Zaretskii <[email-masked]>
Date: Fri, 16 Aug 2024 20:40:07 +0300

> Date: Fri, 16 Aug 2024 16:44:33 +0000
> Cc: Yuan Fu <[email-masked]>, [email-masked]
> From: Alan Mackenzie <[email-masked]>
> 
> Create the file ~/class-3.cc with the following contents:
> /////////////////////////////////////////////////////////////////////////
> // foo
> class A
> {
>     struct B {
>         int i;
>     };
>     struct B {
>         int i;
>     };
> };
> /////////////////////////////////////////////////////////////////////////
> 
> (i) emacs -Q
> (ii) M-x load-library <RET> c-ts-mode <RET>
> (iii) C-x C-f ~/class-3.cc <RET>
> 
> The buffer, in c++-ts-mode, has no fontification apart from the comment
> on its first line.
> 
> > If this happens with any file and in 'emacs -Q", do you see redisplay
> > error messages in *Messages*?  If so, what are those messages?
> 
> Yes, I see a single message after the above recipe.  It's:
> 
> Error during redisplay: (jit-lock-function 1) signaled
> (treesit-query-error "Node type error at" 677 "[\"_Atomic\" \"break\"
> \"case\" \"const\" \"continue\" \"default\" \"do\" \"else\" \"enum\"
> \"extern\" \"for\" \"goto\" \"if\" \"inline\" \"register\" \"restrict\"
> \"return\" \"sizeof\" \"static\" \"struct\" \"switch\" \"typedef\"
> \"union\" \"volatile\" \"while\" \"and\" \"and_eq\" \"bitand\" \"bitor\"
> \"catch\" \"class\" \"co_await\" \"co_return\" \"co_yield\" \"compl\"
> \"\concept\" \"consteval\" \"constexpr\" \"constinit\" \"decltype\"
> \"delete\" \"explicit\" \"final\" \"friend\" \"mutable\" \"namespace\"
> \"new\" \"noexcept\" \"not\" \"not_eq\" \"operator\" \"or\" \"or_eq\"
> \"override\" \"private\" \"protected\" \"public\" \"requires\"
> \"template\" \"throw\" \"try\" \"typename\" \"using\" \"xor\"
> \"xor_eq\"] @font-lock-keyword-face (auto) @font-lock-keyword-face
> (this) @font-lock-keyword-face (virtual) @font-lock-keyword-face" "Debug
> the query with `treesit-query-validate'")
> 
> > > I think I'm using tree-sitter-cpp version 0.22.2 as downloaded from the
> > > Gentoo repository.  Is there an easy way to check this from inside
> > > Emacs?
> 
> > No, not AFAIK.  And the problem is not the version of tree-sitter, it
> > is usually the version of the C++ grammar library.  Do you know the
> > version of that one you have installed?
> 
> I have libtree-sitter-cpp.so.0.14, built and installed on 2024-08-04.
> The package is (confusingly) called dev-libs/tree-sitter-cpp-0.22.2.

I can reproduce this in Emacs 29, but not in the current emacs-30
branch.  I think I also have libtree-sitter-cpp version 0.22.2, but I
also tested with 0.22.3 and I see no problem there, either (with Emacs
30).  So I wonder why you see this in Emacs 30.